repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources16d ago| #1 | import { z } from "zod"; |
| #2 | |
| #3 | export interface GraphToolParameters { |
| #4 | source: string; |
| #5 | destination: string; |
| #6 | relationship: string; |
| #7 | source_type?: string; |
| #8 | destination_type?: string; |
| #9 | } |
| #10 | |
| #11 | export interface GraphEntitiesParameters { |
| #12 | entities: Array<{ |
| #13 | entity: string; |
| #14 | entity_type: string; |
| #15 | }>; |
| #16 | } |
| #17 | |
| #18 | export interface GraphRelationsParameters { |
| #19 | entities: Array<{ |
| #20 | source: string; |
| #21 | relationship: string; |
| #22 | destination: string; |
| #23 | }>; |
| #24 | } |
| #25 | |
| #26 | // --- Zod Schemas for Tool Arguments --- |
| #27 | |
| #28 | // Schema for simple relationship arguments (Update, Delete) |
| #29 | export const GraphSimpleRelationshipArgsSchema = z.object({ |
| #30 | source: z |
| #31 | .string() |
| #32 | .describe("The identifier of the source node in the relationship."), |
| #33 | relationship: z |
| #34 | .string() |
| #35 | .describe("The relationship between the source and destination nodes."), |
| #36 | destination: z |
| #37 | .string() |
| #38 | .describe("The identifier of the destination node in the relationship."), |
| #39 | }); |
| #40 | |
| #41 | // Schema for adding a relationship (includes types) |
| #42 | export const GraphAddRelationshipArgsSchema = |
| #43 | GraphSimpleRelationshipArgsSchema.extend({ |
| #44 | source_type: z |
| #45 | .string() |
| #46 | .describe("The type or category of the source node."), |
| #47 | destination_type: z |
| #48 | .string() |
| #49 | .describe("The type or category of the destination node."), |
| #50 | }); |
| #51 | |
| #52 | // Schema for extracting entities |
| #53 | export const GraphExtractEntitiesArgsSchema = z.object({ |
| #54 | entities: z |
| #55 | .array( |
| #56 | z.object({ |
| #57 | entity: z.string().describe("The name or identifier of the entity."), |
| #58 | entity_type: z.string().describe("The type or category of the entity."), |
| #59 | }), |
| #60 | ) |
| #61 | .describe("An array of entities with their types."), |
| #62 | }); |
| #63 | |
| #64 | // Schema for establishing relationships |
| #65 | export const GraphRelationsArgsSchema = z.object({ |
| #66 | entities: z |
| #67 | .array(GraphSimpleRelationshipArgsSchema) |
| #68 | .describe("An array of relationships (source, relationship, destination)."), |
| #69 | }); |
| #70 | |
| #71 | // --- Tool Definitions (using JSON schema, keep as is) --- |
| #72 | |
| #73 | // Note: The tool definitions themselves still use JSON schema format |
| #74 | // as expected by the LLM APIs. The Zod schemas above are for internal |
| #75 | // validation and potentially for use with Langchain's .withStructuredOutput |
| #76 | // if we adapt it to handle tool calls via schema. |
| #77 | |
| #78 | export const UPDATE_MEMORY_TOOL_GRAPH = { |
| #79 | type: "function", |
| #80 | function: { |
| #81 | name: "update_graph_memory", |
| #82 | description: |
| #83 | "Update the relationship key of an existing graph memory based on new information.", |
| #84 | parameters: { |
| #85 | type: "object", |
| #86 | properties: { |
| #87 | source: { |
| #88 | type: "string", |
| #89 | description: |
| #90 | "The identifier of the source node in the relationship to be updated.", |
| #91 | }, |
| #92 | destination: { |
| #93 | type: "string", |
| #94 | description: |
| #95 | "The identifier of the destination node in the relationship to be updated.", |
| #96 | }, |
| #97 | relationship: { |
| #98 | type: "string", |
| #99 | description: |
| #100 | "The new or updated relationship between the source and destination nodes.", |
| #101 | }, |
| #102 | }, |
| #103 | required: ["source", "destination", "relationship"], |
| #104 | additionalProperties: false, |
| #105 | }, |
| #106 | }, |
| #107 | }; |
| #108 | |
| #109 | export const ADD_MEMORY_TOOL_GRAPH = { |
| #110 | type: "function", |
| #111 | function: { |
| #112 | name: "add_graph_memory", |
| #113 | description: "Add a new graph memory to the knowledge graph.", |
| #114 | parameters: { |
| #115 | type: "object", |
| #116 | properties: { |
| #117 | source: { |
| #118 | type: "string", |
| #119 | description: |
| #120 | "The identifier of the source node in the new relationship.", |
| #121 | }, |
| #122 | destination: { |
| #123 | type: "string", |
| #124 | description: |
| #125 | "The identifier of the destination node in the new relationship.", |
| #126 | }, |
| #127 | relationship: { |
| #128 | type: "string", |
| #129 | description: |
| #130 | "The type of relationship between the source and destination nodes.", |
| #131 | }, |
| #132 | source_type: { |
| #133 | type: "string", |
| #134 | description: "The type or category of the source node.", |
| #135 | }, |
| #136 | destination_type: { |
| #137 | type: "string", |
| #138 | description: "The type or category of the destination node.", |
| #139 | }, |
| #140 | }, |
| #141 | required: [ |
| #142 | "source", |
| #143 | "destination", |
| #144 | "relationship", |
| #145 | "source_type", |
| #146 | "destination_type", |
| #147 | ], |
| #148 | additionalProperties: false, |
| #149 | }, |
| #150 | }, |
| #151 | }; |
| #152 | |
| #153 | export const NOOP_TOOL = { |
| #154 | type: "function", |
| #155 | function: { |
| #156 | name: "noop", |
| #157 | description: "No operation should be performed to the graph entities.", |
| #158 | parameters: { |
| #159 | type: "object", |
| #160 | properties: {}, |
| #161 | required: [], |
| #162 | additionalProperties: false, |
| #163 | }, |
| #164 | }, |
| #165 | }; |
| #166 | |
| #167 | export const RELATIONS_TOOL = { |
| #168 | type: "function", |
| #169 | function: { |
| #170 | name: "establish_relationships", |
| #171 | description: |
| #172 | "Establish relationships among the entities based on the provided text.", |
| #173 | parameters: { |
| #174 | type: "object", |
| #175 | properties: { |
| #176 | entities: { |
| #177 | type: "array", |
| #178 | items: { |
| #179 | type: "object", |
| #180 | properties: { |
| #181 | source: { |
| #182 | type: "string", |
| #183 | description: "The source entity of the relationship.", |
| #184 | }, |
| #185 | relationship: { |
| #186 | type: "string", |
| #187 | description: |
| #188 | "The relationship between the source and destination entities.", |
| #189 | }, |
| #190 | destination: { |
| #191 | type: "string", |
| #192 | description: "The destination entity of the relationship.", |
| #193 | }, |
| #194 | }, |
| #195 | required: ["source", "relationship", "destination"], |
| #196 | additionalProperties: false, |
| #197 | }, |
| #198 | }, |
| #199 | }, |
| #200 | required: ["entities"], |
| #201 | additionalProperties: false, |
| #202 | }, |
| #203 | }, |
| #204 | }; |
| #205 | |
| #206 | export const EXTRACT_ENTITIES_TOOL = { |
| #207 | type: "function", |
| #208 | function: { |
| #209 | name: "extract_entities", |
| #210 | description: "Extract entities and their types from the text.", |
| #211 | parameters: { |
| #212 | type: "object", |
| #213 | properties: { |
| #214 | entities: { |
| #215 | type: "array", |
| #216 | items: { |
| #217 | type: "object", |
| #218 | properties: { |
| #219 | entity: { |
| #220 | type: "string", |
| #221 | description: "The name or identifier of the entity.", |
| #222 | }, |
| #223 | entity_type: { |
| #224 | type: "string", |
| #225 | description: "The type or category of the entity.", |
| #226 | }, |
| #227 | }, |
| #228 | required: ["entity", "entity_type"], |
| #229 | additionalProperties: false, |
| #230 | }, |
| #231 | description: "An array of entities with their types.", |
| #232 | }, |
| #233 | }, |
| #234 | required: ["entities"], |
| #235 | additionalProperties: false, |
| #236 | }, |
| #237 | }, |
| #238 | }; |
| #239 | |
| #240 | export const DELETE_MEMORY_TOOL_GRAPH = { |
| #241 | type: "function", |
| #242 | function: { |
| #243 | name: "delete_graph_memory", |
| #244 | description: "Delete the relationship between two nodes.", |
| #245 | parameters: { |
| #246 | type: "object", |
| #247 | properties: { |
| #248 | source: { |
| #249 | type: "string", |
| #250 | description: "The identifier of the source node in the relationship.", |
| #251 | }, |
| #252 | relationship: { |
| #253 | type: "string", |
| #254 | description: |
| #255 | "The existing relationship between the source and destination nodes that needs to be deleted.", |
| #256 | }, |
| #257 | destination: { |
| #258 | type: "string", |
| #259 | description: |
| #260 | "The identifier of the destination node in the relationship.", |
| #261 | }, |
| #262 | }, |
| #263 | required: ["source", "relationship", "destination"], |
| #264 | additionalProperties: false, |
| #265 | }, |
| #266 | }, |
| #267 | }; |
| #268 |