@carlonicora/nestjs-neo4jsonapi 8.11.1 → 8.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents/community.detector/services/community.detector.service.d.ts +10 -7
- package/dist/agents/community.detector/services/community.detector.service.d.ts.map +1 -1
- package/dist/agents/community.detector/services/community.detector.service.js +26 -31
- package/dist/agents/community.detector/services/community.detector.service.js.map +1 -1
- package/dist/agents/community.summariser/community.summariser.module.d.ts.map +1 -1
- package/dist/agents/community.summariser/community.summariser.module.js +5 -1
- package/dist/agents/community.summariser/community.summariser.module.js.map +1 -1
- package/dist/agents/community.summariser/cron/community.summariser.cron.d.ts +1 -6
- package/dist/agents/community.summariser/cron/community.summariser.cron.d.ts.map +1 -1
- package/dist/agents/community.summariser/cron/community.summariser.cron.js +2 -6
- package/dist/agents/community.summariser/cron/community.summariser.cron.js.map +1 -1
- package/dist/agents/community.summariser/helpers/community-scope-filter.d.ts +3 -5
- package/dist/agents/community.summariser/helpers/community-scope-filter.d.ts.map +1 -1
- package/dist/agents/community.summariser/helpers/community-scope-filter.js +3 -7
- package/dist/agents/community.summariser/helpers/community-scope-filter.js.map +1 -1
- package/dist/agents/community.summariser/processors/community.summariser.processor.d.ts +1 -6
- package/dist/agents/community.summariser/processors/community.summariser.processor.d.ts.map +1 -1
- package/dist/agents/community.summariser/processors/community.summariser.processor.js +2 -6
- package/dist/agents/community.summariser/processors/community.summariser.processor.js.map +1 -1
- package/dist/agents/community.summariser/services/community.summariser.service.js +1 -1
- package/dist/agents/community.summariser/services/community.summariser.service.js.map +1 -1
- package/dist/agents/drift/nodes/followup.node.service.js +1 -1
- package/dist/agents/drift/nodes/followup.node.service.js.map +1 -1
- package/dist/agents/graph/prompts/graph.node.system.prompt.d.ts +19 -2
- package/dist/agents/graph/prompts/graph.node.system.prompt.d.ts.map +1 -1
- package/dist/agents/graph/prompts/graph.node.system.prompt.js +57 -4
- package/dist/agents/graph/prompts/graph.node.system.prompt.js.map +1 -1
- package/dist/agents/graph/services/compact-description.d.ts +76 -0
- package/dist/agents/graph/services/compact-description.d.ts.map +1 -0
- package/dist/agents/graph/services/compact-description.js +178 -0
- package/dist/agents/graph/services/compact-description.js.map +1 -0
- package/dist/agents/graph/services/filter-operators.d.ts +16 -0
- package/dist/agents/graph/services/filter-operators.d.ts.map +1 -0
- package/dist/agents/graph/services/filter-operators.js +35 -0
- package/dist/agents/graph/services/filter-operators.js.map +1 -0
- package/dist/agents/graph/tools/describe-entity.tool.d.ts +57 -1
- package/dist/agents/graph/tools/describe-entity.tool.d.ts.map +1 -1
- package/dist/agents/graph/tools/describe-entity.tool.js +121 -59
- package/dist/agents/graph/tools/describe-entity.tool.js.map +1 -1
- package/dist/agents/graph/tools/read-entity.tool.d.ts.map +1 -1
- package/dist/agents/graph/tools/read-entity.tool.js +11 -2
- package/dist/agents/graph/tools/read-entity.tool.js.map +1 -1
- package/dist/agents/graph/tools/search-entities.tool.d.ts.map +1 -1
- package/dist/agents/graph/tools/search-entities.tool.js +7 -2
- package/dist/agents/graph/tools/search-entities.tool.js.map +1 -1
- package/dist/agents/graph/tools/tool.factory.d.ts +35 -0
- package/dist/agents/graph/tools/tool.factory.d.ts.map +1 -1
- package/dist/agents/graph/tools/tool.factory.js +34 -0
- package/dist/agents/graph/tools/tool.factory.js.map +1 -1
- package/dist/agents/graph/tools/traverse.tool.d.ts +1 -13
- package/dist/agents/graph/tools/traverse.tool.d.ts.map +1 -1
- package/dist/agents/graph/tools/traverse.tool.js +13 -33
- package/dist/agents/graph/tools/traverse.tool.js.map +1 -1
- package/dist/agents/index.d.ts +6 -2
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +10 -2
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/responder/nodes/graph.node.service.d.ts +48 -1
- package/dist/agents/responder/nodes/graph.node.service.d.ts.map +1 -1
- package/dist/agents/responder/nodes/graph.node.service.js +158 -41
- package/dist/agents/responder/nodes/graph.node.service.js.map +1 -1
- package/dist/agents/responder/nodes/responder.answer.node.service.d.ts +1 -1
- package/dist/agents/responder/nodes/responder.answer.node.service.d.ts.map +1 -1
- package/dist/agents/responder/nodes/responder.answer.node.service.js +14 -0
- package/dist/agents/responder/nodes/responder.answer.node.service.js.map +1 -1
- package/dist/config/base.config.d.ts +6 -0
- package/dist/config/base.config.d.ts.map +1 -1
- package/dist/config/base.config.js +1 -0
- package/dist/config/base.config.js.map +1 -1
- package/dist/config/interfaces/base.config.interface.d.ts +2 -0
- package/dist/config/interfaces/base.config.interface.d.ts.map +1 -1
- package/dist/config/interfaces/config.community.interface.d.ts +8 -0
- package/dist/config/interfaces/config.community.interface.d.ts.map +1 -0
- package/dist/config/interfaces/config.community.interface.js +3 -0
- package/dist/config/interfaces/config.community.interface.js.map +1 -0
- package/dist/config/interfaces/config.prompts.interface.d.ts +4 -4
- package/dist/config/interfaces/config.responder.interface.d.ts +7 -6
- package/dist/config/interfaces/config.responder.interface.d.ts.map +1 -1
- package/dist/config/interfaces/index.d.ts +1 -0
- package/dist/config/interfaces/index.d.ts.map +1 -1
- package/dist/config/interfaces/index.js +1 -0
- package/dist/config/interfaces/index.js.map +1 -1
- package/dist/core/llm/services/llm.service.d.ts +26 -0
- package/dist/core/llm/services/llm.service.d.ts.map +1 -1
- package/dist/core/llm/services/llm.service.js +146 -14
- package/dist/core/llm/services/llm.service.js.map +1 -1
- package/dist/foundations/analytics/index.d.ts +1 -0
- package/dist/foundations/analytics/index.d.ts.map +1 -1
- package/dist/foundations/analytics/index.js +3 -1
- package/dist/foundations/analytics/index.js.map +1 -1
- package/dist/foundations/analytics/interfaces/analytics.purge-visitor.input.d.ts +19 -0
- package/dist/foundations/analytics/interfaces/analytics.purge-visitor.input.d.ts.map +1 -0
- package/dist/foundations/analytics/interfaces/analytics.purge-visitor.input.js +6 -0
- package/dist/foundations/analytics/interfaces/analytics.purge-visitor.input.js.map +1 -0
- package/dist/foundations/analytics/processors/analytics.processor.d.ts +10 -1
- package/dist/foundations/analytics/processors/analytics.processor.d.ts.map +1 -1
- package/dist/foundations/analytics/processors/analytics.processor.js +29 -0
- package/dist/foundations/analytics/processors/analytics.processor.js.map +1 -1
- package/dist/foundations/analytics/repositories/analytics-session.repository.d.ts +11 -0
- package/dist/foundations/analytics/repositories/analytics-session.repository.d.ts.map +1 -1
- package/dist/foundations/analytics/repositories/analytics-session.repository.js +37 -0
- package/dist/foundations/analytics/repositories/analytics-session.repository.js.map +1 -1
- package/dist/foundations/analytics/services/analytics.service.d.ts +3 -1
- package/dist/foundations/analytics/services/analytics.service.d.ts.map +1 -1
- package/dist/foundations/analytics/services/analytics.service.js +18 -3
- package/dist/foundations/analytics/services/analytics.service.js.map +1 -1
- package/dist/foundations/community/community.module.d.ts.map +1 -1
- package/dist/foundations/community/community.module.js +5 -4
- package/dist/foundations/community/community.module.js.map +1 -1
- package/dist/foundations/community/entities/community.entity.d.ts +30 -4
- package/dist/foundations/community/entities/community.entity.d.ts.map +1 -1
- package/dist/foundations/community/entities/community.entity.js +51 -0
- package/dist/foundations/community/entities/community.entity.js.map +1 -1
- package/dist/foundations/community/index.d.ts +4 -2
- package/dist/foundations/community/index.d.ts.map +1 -1
- package/dist/foundations/community/index.js +8 -3
- package/dist/foundations/community/index.js.map +1 -1
- package/dist/foundations/community/repositories/community.repository.d.ts +93 -103
- package/dist/foundations/community/repositories/community.repository.d.ts.map +1 -1
- package/dist/foundations/community/repositories/community.repository.js +330 -328
- package/dist/foundations/community/repositories/community.repository.js.map +1 -1
- package/dist/foundations/community/services/community-layer.service.d.ts +38 -0
- package/dist/foundations/community/services/community-layer.service.d.ts.map +1 -0
- package/dist/foundations/community/services/community-layer.service.js +89 -0
- package/dist/foundations/community/services/community-layer.service.js.map +1 -0
- package/dist/foundations/community/services/community.service.d.ts +22 -4
- package/dist/foundations/community/services/community.service.d.ts.map +1 -1
- package/dist/foundations/community/services/community.service.js +9 -6
- package/dist/foundations/community/services/community.service.js.map +1 -1
- package/package.json +1 -1
- package/dist/foundations/community/entities/community.map.d.ts +0 -8
- package/dist/foundations/community/entities/community.map.d.ts.map +0 -1
- package/dist/foundations/community/entities/community.map.js +0 -24
- package/dist/foundations/community/entities/community.map.js.map +0 -1
- package/dist/foundations/community/entities/community.model.d.ts +0 -4
- package/dist/foundations/community/entities/community.model.d.ts.map +0 -1
- package/dist/foundations/community/entities/community.model.js +0 -15
- package/dist/foundations/community/entities/community.model.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"followup.node.service.js","sourceRoot":"","sources":["../../../../src/agents/drift/nodes/followup.node.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,2CAA+C;AAC/C,6BAAwB;AAExB,wEAAoE;AACpE,oFAAmF;AACnF,2GAAuG;AAEvG,sEAA2E;AAE9D,QAAA,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;CAsBpC,CAAC;AAEF,MAAM,YAAY,GAAG,OAAC,CAAC,MAAM,CAAC;IAC5B,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,2DAA2D,CAAC;IACxF,mBAAmB,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,6DAA6D,CAAC;IAChH,cAAc,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,2CAA2C,CAAC;CAClF,CAAC,CAAC;AAEH,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3B,gBAAgB,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,4BAA4B,CAAC;IACnE,gBAAgB,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,0CAA0C,CAAC;IACjF,YAAY,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,iDAAiD,CAAC;IACpF,gBAAgB,EAAE,OAAC,CAAC,MAAM,E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AG,KAAK,CAAC,YAAY,UAAU,eAAe,QAAQ,WAAW,CAAC,MAAM,EAAE,CAAC;QAEvG,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,8CAA8C,WAAW,CAAC,mBAAmB,CAAC,MAAM,uBAAuB,EAC3G,qBAAqB,CACtB,CAAC;QAEF,OAAO;YACL,IAAI,EAAE,CAAC;YACP,eAAe,EAAE,CAAC,cAAc,CAAC;YACjC,YAAY,EAAE,mBAAmB;YACjC,oBAAoB,EAAE,YAAY,GAAG,CAAC;YACtC,MAAM,EAAE,WAAW,CAAC,UAAU;YAC9B,QAAQ,EAAE,UAAU,EAAE,iCAAiC;SACxD,CAAC;IACJ,CAAC;IAED;;OAEG;IACK,0BAA0B,CAAC,eAAiC;QAClE,MAAM,SAAS,GAAa,EAAE,CAAC;QAC/B,KAAK,MAAM,MAAM,IAAI,eAAe,EAAE,CAAC;YACrC,IAAI,MAAM,CAAC,cAAc,IAAI,MAAM,CAAC,mBAAmB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACnE,SAAS,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAC;YAChD,CAAC;QACH,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,sBAAsB,CAAC,YAAsB;QACzD,MAAM,OAAO,GAAa,EAAE,CAAC;QAE7B,KAAK,MAAM,WAAW,IAAI,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;YACnD,IAAI,CAAC;gBACH,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC,
|
|
1
|
+
{"version":3,"file":"followup.node.service.js","sourceRoot":"","sources":["../../../../src/agents/drift/nodes/followup.node.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,2CAA+C;AAC/C,6BAAwB;AAExB,wEAAoE;AACpE,oFAAmF;AACnF,2GAAuG;AAEvG,sE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W,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;oBAClF,CAAC,CAAC,+BAA+B,CAAC;gBAEtC,OAAO,CAAC,IAAI,CAAC,MAAM,SAAS,CAAC,IAAI,iBAAiB,aAAa,uBAAuB,mBAAmB,EAAE,CAAC,CAAC;YAC/G,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,0CAA0C,WAAW,KAAM,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;YACzG,CAAC;QACH,CAAC;QAED,OAAO,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACrC,CAAC;CACF,CAAA;AAhJY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,mBAAU,GAAE;qCAMoB,wBAAU;QACD,0CAAmB;QAChC,mCAAiB;QACV,sBAAa;GARpC,mBAAmB,CAgJ/B"}
|
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
import { GraphNodeDomainPrompts } from "../../../config/interfaces/config.prompts.interface";
|
|
2
|
-
export declare const GRAPH_NODE_SYSTEM_PROMPT_BASE = "# Role\n\n{DOMAIN_ROLE}\n\nThe data is stored as a graph \u2014 entities are nodes, and the connections between them are edges.\n\nYou answer the user's questions by traversing this graph: find the entities the question is about, read their fields, and walk the relationships between them to reach related entities, continuing until you have enough information to answer. Nearly every useful answer requires following at least one edge \u2014 a single search is rarely the whole story.\n\nEvery fact in your answer must come from a tool call that returned it. Do not invent field names, relationship names, entity types, or record contents.\n\n## Your data\n\n{GRAPH_MAP}\n\nThe list above is the complete inventory of entity types available to you \u2014 anything not listed does not exist. Each entry shows only the type and a one-line description; fields and relationships are not included here. To learn the fields and relationships of any type, call `describe_entity({ type })` \u2014 its response is the only authoritative source for that type's schema. Do not assume a field or relationship exists until `describe_entity` confirms it.\n\nA field marked `money` in the catalogue above is stored as an integer in minor units; its marker states how many decimals (e.g. `total_amount (number, money [integer stored in minor units (2 decimals); divide by 10^2 to display], ...)`). For these fields, every record returned by `read_entity`, `search_entities`, or `traverse` also carries a sibling `<name>_formatted` string \u2014 quote that string when narrating the value in your answer, and never quote the raw integer as if it were the display amount. Filters and sort still target the raw field, in minor units.\n\n{DOMAIN_DATA_CONVENTIONS}\n\n## Tools\n\nYou have five tools.\n\n**Never ask the user a clarifying question.** The user expects an answer, not a follow-up. After `resolve_entity` returns at least one usable candidate, immediately continue: `describe_entity` \u2192 `search_entities` / `traverse` / `read_entity` \u2192 answer. Do not stop the tool chain to confirm what to do next. If multiple candidates of different types could match, pick the one whose type and connected relationships best fit the user's question. State the assumption you made in the `reason` clause of the entity you return; do not ask the user.\n\n{DOMAIN_DISAMBIGUATION}\n\nBefore choosing a tool, check the \"Entities already in this conversation\" block that may be provided below. If the user's phrase refers to an entity listed there \u2014 by its exact name, by a partial name, or implicitly (\"them\", \"their\", \"other\", \"these\") \u2014 treat that entity as resolved. Use its `type` and `id` directly with `read_entity` or `traverse`. **A previous-turn record's nested relationships also carry their own `{ type, id }` \u2014 those ids are addressable, so call `read_entity` or `traverse` with them directly.** Do not call `resolve_entity` for a name that is already resolved in context, and do not call `resolve_entity` for a record whose id you already have.\n\nOtherwise, if the user names an entity \u2014 a person, a place, an organisation, a project, anything that could correspond to a record in the graph \u2014 your first tool call is `resolve_entity` with the user's literal phrase. Do not guess a type. `resolve_entity` returns candidates across every entity type in one shot; you then pick a candidate and proceed with `describe_entity` + the typed tools.\n\nSome entities in the catalog are marked `(bridge \u2192 \u2026)` in the type index. A bridge is a junction record whose own fields are minimal \u2014 the actionable data lives on the relationships named in the bridge marker. When `traverse`, `read_entity`, or `search_entities` returns a record of a bridge type, the response already contains those relationships' targets inlined as nested objects, alongside a `__materialised: [...]` array listing which keys were filled. Do not call `traverse` on a relationship that already appears in `__materialised` \u2014 its content is already in front of you. If a relationship is in the bridge's `materialiseTo` per `describe_entity` but missing from `__materialised`, the target is gated by your module access; do not retry that traverse \u2014 narrate the gap to the user.\n\n- `resolve_entity(text)` \u2014 look up nodes by name across every entity type in one call. Pass the user's literal phrase verbatim, including words like \"and\", \"&\", or other punctuation that may be part of a name. The response carries a `matchMode`, `items` sorted by `score` descending, and an optional `recommendation`:\n - exact, substring or fuzzy \u2192\n - **If the response carries `recommendation`, follow it.** It surfaces a deterministic rule already applied to the candidates and is more reliable than re-deriving the rule each turn.\n - Otherwise: if `items[0].summary` equals the user's literal phrase (case-insensitive), `items[0]` is the answer \u2014 pick it without further disambiguation. Words like \"and\", \"&\", or commas inside that phrase are part of the name; never split the phrase into multiple `resolve_entity` calls and never ask the user to clarify between `items[0]` and lower-ranked items just because the phrase looks plural.\n - Exception: if the response carries a disambiguation field, two or more candidates share the same summary. Do NOT pick items[0], even when its summary equals the user's literal phrase; this overrides the literal-match rule above. Ask the user for court, sezione or type, or call search_entities with those filters.\n - Otherwise: if `items.length === 1` or `items[0].score - items[1].score \u2265 0.15`, pick `items[0]`.\n - Otherwise: pick the most plausible candidate by name match and continue traversing \u2014 the question still has to be answered. Do not refuse the user when at least one usable candidate exists.\n - `semantic` \u2192 same rules, margin \u2265 0.08. The match is approximate; reflect that in the `reason` clause.\n - `none` \u2192 no record exists; tell the user in your answer and suggest rephrasing.\n\n- `describe_entity(type)` \u2014 inspect one entity type in full: every field with its type, and every relationship with its target type and description. Call this for every type you intend to touch, before searching, reading, or traversing it. The next three tools will refuse to run on a type that has not been described in this turn.\n\n- `search_entities(type, filters?, sort?, limit?)` \u2014 find records of a known type by filter and sort. Use this when you already have the type (from `resolve_entity` or because the user referred to a kind of record without naming a specific one, e.g. \"all records of that type created after a given date\"). `search_entities` does not search by name \u2014 to find a record by name, call `resolve_entity` first. Unlike resolve_entity, the response carries no matchMode: it carries applied ({ filters, sort, limit }), the filters, sort and limit that actually ran, next to items. Read applied before reporting a result, and describe the result in terms of what ran.\n\n- `read_entity(type, id, include?)` \u2014 fetch the full fields of a single node by id. Tool outputs from other tools are summaries; call this to get the complete record before reporting on it. Calling `read_entity` again for a record already returned in full earlier in this conversation is refused with `{ alreadyRead: true }` \u2014 reuse the copy you already have instead of re-reading.\n\n- `traverse(fromType, fromId, relationship, filters?, sort?, limit?)` \u2014 walk one edge from a known node to its connected nodes. The `relationship` must be one listed under the source type in the catalogue. `filters` and `sort` apply to the target node's fields. This is the only way to cross from one entity type to another. A relationship named `related` is polymorphic: it returns records of mixed types linked to the source by mentions or GM-drawn links, each item tagged with its own `type` \u2014 treat each exactly like a `search_entities` result of that type; filters and sort do not apply to it.\n\nA list item from `search_entities` or `traverse` may carry `availableOnRead`: those fields exist on that record and were withheld from the list for size \u2014 call `read_entity` with the item's `type` and `id` to obtain them. A field absent from both `fields` and `availableOnRead` is empty, not withheld.\n\n{DOMAIN_DEPTH}\n\nIf a tool returns `{ error: \"\u2026\" }`, read the message \u2014 it usually lists valid fields or relationships, or tells you to call `describe_entity` first. Pick one of those and call the tool again. Recover within the same turn; do not apologise to the user for a tool error. Never stop on the first error.\n\n## Output\n\nReturn these fields:\n\n- `answer` \u2014 a concise prose reply (2\u20134 sentences for a single record, a markdown bullet list when enumerating) built from the actual field values and traversal results. When you report on a record, use its real field values, not its type name. When you report a money value, quote the `<name>_formatted` string from the record. When you report a date, use the date as it appears in the record.\n\n{DOMAIN_OUTPUT_RULES}\n\n- `entities` \u2014 every entity that contributes to the meaning of your `answer`, as `{ type, id, reason, fields? }`. An entity contributes when it is the subject the user asked about, or a record the answer reports a fact about. `reason` is one short clause explaining that role (for example \"the account the user asked about\", \"one of the records listed in the answer\"). Populate `fields` with the values you quoted in `answer`. Do not include entities you retrieved, inspected, and discarded: a `resolve_entity` call that returned three candidates of which you only used one \u2014 the other two are not entities to return; a `traverse` that walked an edge whose target you did not mention \u2014 not an entity. These entities are persisted and re-loaded as context on the next turn, so polluting them with irrelevant records will cause the next turn to confuse them with the actual subject \u2014 be strict.\n\n- `stop` \u2014 set to `true` once `answer` is complete and `entities` is the matching set.\n";
|
|
2
|
+
export declare const GRAPH_NODE_SYSTEM_PROMPT_BASE = "# Role\n\n{DOMAIN_ROLE}\n\nThe data is stored as a graph \u2014 entities are nodes, and the connections between them are edges.\n\nYou answer the user's questions by traversing this graph: find the entities the question is about, read their fields, and walk the relationships between them to reach related entities, continuing until you have enough information to answer. Nearly every useful answer requires following at least one edge \u2014 a single search is rarely the whole story.\n\nEvery fact in your answer must come from a tool call that returned it. Do not invent field names, relationship names, entity types, or record contents.\n\n## Your data\n\n{GRAPH_MAP}\n\nThe list above is the complete inventory of entity types available to you \u2014 anything not listed does not exist. Each entry shows only the type and a one-line description; fields and relationships are not included here. To learn the fields and relationships of any type, call `describe_entity({ type })` \u2014 its response is the only authoritative source for that type's schema. Do not assume a field or relationship exists until `describe_entity` confirms it.\n\nA field marked `money` in the catalogue above is stored as an integer in minor units; its marker states how many decimals (e.g. `total_amount (number, money [integer stored in minor units (2 decimals); divide by 10^2 to display], ...)`). For these fields, every record returned by `read_entity`, `search_entities`, or `traverse` also carries a sibling `<name>_formatted` string \u2014 quote that string when narrating the value in your answer, and never quote the raw integer as if it were the display amount. Filters and sort still target the raw field, in minor units.\n\n{DOMAIN_DATA_CONVENTIONS}\n\n## Tools\n\nYou have five tools.\n\n**Never ask the user a clarifying question.** The user expects an answer, not a follow-up. After `resolve_entity` returns at least one usable candidate, immediately continue: `describe_entity` \u2192 `search_entities` / `traverse` / `read_entity` \u2192 answer. Do not stop the tool chain to confirm what to do next. If multiple candidates of different types could match, pick the one whose type and connected relationships best fit the user's question. State the assumption you made in the `reason` clause of the entity you return; do not ask the user.\n\n{DOMAIN_DISAMBIGUATION}\n\nBefore choosing a tool, check the \"Entities already in this conversation\" block that may be provided below. If the user's phrase refers to an entity listed there \u2014 by its exact name, by a partial name, or implicitly (\"them\", \"their\", \"other\", \"these\") \u2014 treat that entity as resolved. Use its `type` and `id` directly with `read_entity` or `traverse`. **A previous-turn record's nested relationships also carry their own `{ type, id }` \u2014 those ids are addressable, so call `read_entity` or `traverse` with them directly.** Do not call `resolve_entity` for a name that is already resolved in context, and do not call `resolve_entity` for a record whose id you already have.\n\nOtherwise, if the user names an entity \u2014 a person, a place, an organisation, a project, anything that could correspond to a record in the graph \u2014 your first tool call is `resolve_entity` with the user's literal phrase. Do not guess a type. `resolve_entity` returns candidates across every entity type in one shot; you then pick a candidate and proceed with `describe_entity` + the typed tools.\n\nSome entities in the catalog are marked `(bridge \u2192 \u2026)` in the type index. A bridge is a junction record whose own fields are minimal \u2014 the actionable data lives on the relationships named in the bridge marker. When `traverse`, `read_entity`, or `search_entities` returns a record of a bridge type, the response already contains those relationships' targets inlined as nested objects, alongside a `__materialised: [...]` array listing which keys were filled. Do not call `traverse` on a relationship that already appears in `__materialised` \u2014 its content is already in front of you. If a relationship is in the bridge's `materialiseTo` per `describe_entity` but missing from `__materialised`, the target is gated by your module access; do not retry that traverse \u2014 narrate the gap to the user.\n\n- `resolve_entity(text)` \u2014 look up nodes by name across every entity type in one call. Pass the user's literal phrase verbatim, including words like \"and\", \"&\", or other punctuation that may be part of a name. The response carries a `matchMode`, `items` sorted by `score` descending, and an optional `recommendation`:\n - exact, substring or fuzzy \u2192\n - **If the response carries `recommendation`, follow it.** It surfaces a deterministic rule already applied to the candidates and is more reliable than re-deriving the rule each turn.\n - Otherwise: if `items[0].summary` equals the user's literal phrase (case-insensitive), `items[0]` is the answer \u2014 pick it without further disambiguation. Words like \"and\", \"&\", or commas inside that phrase are part of the name; never split the phrase into multiple `resolve_entity` calls and never ask the user to clarify between `items[0]` and lower-ranked items just because the phrase looks plural.\n - Exception: if the response carries a disambiguation field, two or more candidates share the same summary. Do NOT pick items[0], even when its summary equals the user's literal phrase; this overrides the literal-match rule above. Ask the user for court, sezione or type, or call search_entities with those filters.\n - Otherwise: if `items.length === 1` or `items[0].score - items[1].score \u2265 0.15`, pick `items[0]`.\n - Otherwise: pick the most plausible candidate by name match and continue traversing \u2014 the question still has to be answered. Do not refuse the user when at least one usable candidate exists.\n - `semantic` \u2192 same rules, margin \u2265 0.08. The match is approximate; reflect that in the `reason` clause.\n - `none` \u2192 no record exists; tell the user in your answer and suggest rephrasing.\n\n- `describe_entity(type)` \u2014 inspect one entity type in full: every field with its type, and every relationship with its target type and description. Call this for every type you intend to touch, before searching, reading, or traversing it. The next three tools will refuse to run on a type that has not been described in this turn.\n\n- `search_entities(type, filters?, sort?, limit?)` \u2014 find records of a known type by filter and sort. Use this when you already have the type (from `resolve_entity` or because the user referred to a kind of record without naming a specific one, e.g. \"all records of that type created after a given date\"). `search_entities` does not search by name \u2014 to find a record by name, call `resolve_entity` first. Unlike resolve_entity, the response carries no matchMode: it carries applied ({ filters, sort, limit }), the filters, sort and limit that actually ran, next to items. Read applied before reporting a result, and describe the result in terms of what ran.\n\n- `read_entity(type, id, include?)` \u2014 fetch the full fields of a single node by id. Tool outputs from other tools are summaries; call this to get the complete record before reporting on it. Calling `read_entity` again for a record already returned in full earlier in this conversation is refused with `{ alreadyRead: true }` \u2014 reuse the copy you already have instead of re-reading.\n\n- `traverse(fromType, fromId, relationship, filters?, sort?, limit?)` \u2014 walk one edge from a known node to its connected nodes. The `relationship` must be one listed under the source type in the catalogue. `filters` and `sort` apply to the target node's fields. This is the only way to cross from one entity type to another. A relationship named `related` is polymorphic: it returns records of mixed types linked to the source by mentions or GM-drawn links, each item tagged with its own `type` \u2014 treat each exactly like a `search_entities` result of that type; filters and sort do not apply to it.\n\nA list item from `search_entities` or `traverse` may carry `availableOnRead`: those fields exist on that record and were withheld from the list for size \u2014 call `read_entity` with the item's `type` and `id` to obtain them. A field absent from both `fields` and `availableOnRead` is empty, not withheld.\n\n{DOMAIN_DEPTH}\n\nIf a tool returns `{ error: \"\u2026\" }`, read the message \u2014 it usually lists valid fields or relationships, or tells you to call `describe_entity` first. Pick one of those and call the tool again. Recover within the same turn; do not apologise to the user for a tool error. Never stop on the first error.\n\n## Output\n\nReturn these fields:\n\n- `answer` \u2014 a concise prose reply (2\u20134 sentences for a single record, a markdown bullet list when enumerating) built from the actual field values and traversal results. When you report on a record, use its real field values, not its type name. When you report a money value, quote the `<name>_formatted` string from the record. When you report a date, use the date as it appears in the record.\n\n{DOMAIN_OUTPUT_RULES}\n\n- `entities` \u2014 every entity that contributes to the meaning of your `answer`, as `{ type, id, reason }`. An entity contributes when it is the subject the user asked about, or a record the answer reports a fact about. `reason` is one short clause explaining that role (for example \"the account the user asked about\", \"one of the records listed in the answer\"). Do not include entities you retrieved, inspected, and discarded: a `resolve_entity` call that returned three candidates of which you only used one \u2014 the other two are not entities to return; a `traverse` that walked an edge whose target you did not mention \u2014 not an entity. These entities are persisted and re-loaded as context on the next turn, so polluting them with irrelevant records will cause the next turn to confuse them with the actual subject \u2014 be strict.\n\n- `stop` \u2014 set to `true` once `answer` is complete and `entities` is the matching set.\n";
|
|
3
|
+
/**
|
|
4
|
+
* The base text for up-front mode: today's base with the "Your data" paragraph,
|
|
5
|
+
* the describe_entity Tools entry and the two paragraphs that chain
|
|
6
|
+
* describe_entity after resolve_entity swapped for their up-front wording. Every
|
|
7
|
+
* other line is the same as {@link GRAPH_NODE_SYSTEM_PROMPT_BASE}.
|
|
8
|
+
*/
|
|
9
|
+
export declare const GRAPH_NODE_SYSTEM_PROMPT_UPFRONT_BASE: string;
|
|
3
10
|
export declare function describeDomainLayer(domain?: GraphNodeDomainPrompts): string;
|
|
4
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Renders the graph node's system prompt.
|
|
13
|
+
*
|
|
14
|
+
* @param graphMap the one-line type index of the user's readable types.
|
|
15
|
+
* @param domain the app's domain text for the DOMAIN slots.
|
|
16
|
+
* @param catalog the compact descriptions of every type in `graphMap`
|
|
17
|
+
* (`DescribeEntityTool.renderCatalog`). Given, the prompt says the types are
|
|
18
|
+
* already described and describe_entity is not needed for them; absent, the
|
|
19
|
+
* prompt is today's, byte for byte (describe every type first).
|
|
20
|
+
*/
|
|
21
|
+
export declare function renderGraphNodeSystemPrompt(graphMap: string, domain?: GraphNodeDomainPrompts, catalog?: string): string;
|
|
5
22
|
//# sourceMappingURL=graph.node.system.prompt.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph.node.system.prompt.d.ts","sourceRoot":"","sources":["../../../../src/agents/graph/prompts/graph.node.system.prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,qDAAqD,CAAC;AAE7F,eAAO,MAAM,6BAA6B,
|
|
1
|
+
{"version":3,"file":"graph.node.system.prompt.d.ts","sourceRoot":"","sources":["../../../../src/agents/graph/prompts/graph.node.system.prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,qDAAqD,CAAC;AAE7F,eAAO,MAAM,6BAA6B,m9TAqEzC,CAAC;AAiCF;;;;;GAKG;AACH,eAAO,MAAM,qCAAqC,QAO8D,CAAC;AAMjH,wBAAgB,mBAAmB,CAAC,MAAM,CAAC,EAAE,sBAAsB,GAAG,MAAM,CAG3E;AAED;;;;;;;;;GASG;AACH,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,sBAAsB,EAC/B,OAAO,CAAC,EAAE,MAAM,GACf,MAAM,CAoBR"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GRAPH_NODE_SYSTEM_PROMPT_BASE = void 0;
|
|
3
|
+
exports.GRAPH_NODE_SYSTEM_PROMPT_UPFRONT_BASE = exports.GRAPH_NODE_SYSTEM_PROMPT_BASE = void 0;
|
|
4
4
|
exports.describeDomainLayer = describeDomainLayer;
|
|
5
5
|
exports.renderGraphNodeSystemPrompt = renderGraphNodeSystemPrompt;
|
|
6
6
|
exports.GRAPH_NODE_SYSTEM_PROMPT_BASE = `# Role
|
|
@@ -69,20 +69,70 @@ Return these fields:
|
|
|
69
69
|
|
|
70
70
|
{DOMAIN_OUTPUT_RULES}
|
|
71
71
|
|
|
72
|
-
- \`entities\` — every entity that contributes to the meaning of your \`answer\`, as \`{ type, id, reason
|
|
72
|
+
- \`entities\` — every entity that contributes to the meaning of your \`answer\`, as \`{ type, id, reason }\`. An entity contributes when it is the subject the user asked about, or a record the answer reports a fact about. \`reason\` is one short clause explaining that role (for example "the account the user asked about", "one of the records listed in the answer"). Do not include entities you retrieved, inspected, and discarded: a \`resolve_entity\` call that returned three candidates of which you only used one — the other two are not entities to return; a \`traverse\` that walked an edge whose target you did not mention — not an entity. These entities are persisted and re-loaded as context on the next turn, so polluting them with irrelevant records will cause the next turn to confuse them with the actual subject — be strict.
|
|
73
73
|
|
|
74
74
|
- \`stop\` — set to \`true\` once \`answer\` is complete and \`entities\` is the matching set.
|
|
75
75
|
`;
|
|
76
|
+
/**
|
|
77
|
+
* Up-front replacement of the "Your data" paragraph that follows the type
|
|
78
|
+
* index: the full catalog is given here, so the model is not told to describe
|
|
79
|
+
* each type before touching it.
|
|
80
|
+
*/
|
|
81
|
+
const UPFRONT_DATA_PARAGRAPH = `The list above is the complete inventory of entity types available to you — anything not listed does not exist. The full description of every one of these types follows: its fields and relationships, which fields can be filtered and sorted, and with which operators.
|
|
82
|
+
|
|
83
|
+
{GRAPH_CATALOG}
|
|
84
|
+
|
|
85
|
+
These descriptions are the only authoritative source for each type's schema, and every type in the list above counts as already described: search, read and traverse it directly, without a describe_entity call first. Do not assume a field or relationship exists unless its type's description above lists it.`;
|
|
86
|
+
/** Up-front replacement of the describe_entity entry under "Tools". */
|
|
87
|
+
const UPFRONT_DESCRIBE_TOOL_ENTRY = `- describe_entity(type) — returns the description of one entity type. Every type in the inventory is already described in full under "Your data", so it is not needed for those types; use it only for a type whose description you cannot find there.`;
|
|
88
|
+
/** Up-front replacement of the "Never ask the user a clarifying question" paragraph: the tool chain skips describe_entity. */
|
|
89
|
+
const UPFRONT_NO_CLARIFYING_PARAGRAPH = `**Never ask the user a clarifying question.** The user expects an answer, not a follow-up. After resolve_entity returns at least one usable candidate, immediately continue: search_entities / traverse / read_entity → answer. Do not stop the tool chain to confirm what to do next. If multiple candidates of different types could match, pick the one whose type and connected relationships best fit the user's question. State the assumption you made in the reason clause of the entity you return; do not ask the user.`;
|
|
90
|
+
/** Up-front replacement of the resolve_entity paragraph: the candidate's type is already described. */
|
|
91
|
+
const UPFRONT_RESOLVE_PARAGRAPH = `Otherwise, if the user names an entity — a person, a place, an organisation, a project, anything that could correspond to a record in the graph — your first tool call is resolve_entity with the user's literal phrase. Do not guess a type. resolve_entity returns candidates across every entity type in one shot; you then pick a candidate and proceed with the typed tools, using its type's description under "Your data".`;
|
|
92
|
+
const TODAY_DATA_PARAGRAPH = /^The list above is the complete inventory of entity types available to you.*$/m;
|
|
93
|
+
// \x60 is a backtick, kept out of this file's new text.
|
|
94
|
+
const TODAY_DESCRIBE_TOOL_ENTRY = /^- \x60describe_entity\(type\)\x60 .*$/m;
|
|
95
|
+
const TODAY_NO_CLARIFYING_PARAGRAPH = /^\*\*Never ask the user a clarifying question\.\*\*.*$/m;
|
|
96
|
+
const TODAY_RESOLVE_PARAGRAPH = /^Otherwise, if the user names an entity .*$/m;
|
|
97
|
+
function replaceLineOnce(text, line, replacement) {
|
|
98
|
+
if (!line.test(text))
|
|
99
|
+
throw new Error(`graph node system prompt: line ${line} not found`);
|
|
100
|
+
return text.replace(line, () => replacement);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* The base text for up-front mode: today's base with the "Your data" paragraph,
|
|
104
|
+
* the describe_entity Tools entry and the two paragraphs that chain
|
|
105
|
+
* describe_entity after resolve_entity swapped for their up-front wording. Every
|
|
106
|
+
* other line is the same as {@link GRAPH_NODE_SYSTEM_PROMPT_BASE}.
|
|
107
|
+
*/
|
|
108
|
+
exports.GRAPH_NODE_SYSTEM_PROMPT_UPFRONT_BASE = [
|
|
109
|
+
[TODAY_DATA_PARAGRAPH, UPFRONT_DATA_PARAGRAPH],
|
|
110
|
+
[TODAY_DESCRIBE_TOOL_ENTRY, UPFRONT_DESCRIBE_TOOL_ENTRY],
|
|
111
|
+
[TODAY_NO_CLARIFYING_PARAGRAPH, UPFRONT_NO_CLARIFYING_PARAGRAPH],
|
|
112
|
+
[TODAY_RESOLVE_PARAGRAPH, UPFRONT_RESOLVE_PARAGRAPH],
|
|
113
|
+
].reduce((text, [line, replacement]) => replaceLineOnce(text, line, replacement), exports.GRAPH_NODE_SYSTEM_PROMPT_BASE);
|
|
76
114
|
const DEFAULT_ROLE = "You help a user explore their organisation's data.";
|
|
77
115
|
const DOMAIN_SLOTS = ["role", "depth", "disambiguation", "dataConventions", "outputRules"];
|
|
78
116
|
function describeDomainLayer(domain) {
|
|
79
117
|
const parts = DOMAIN_SLOTS.map((slot) => `${slot}=${domain?.[slot]?.trim() ? "supplied" : "kernel"}`);
|
|
80
118
|
return `graph node domain layer: ${parts.join(" ")}`;
|
|
81
119
|
}
|
|
82
|
-
|
|
120
|
+
/**
|
|
121
|
+
* Renders the graph node's system prompt.
|
|
122
|
+
*
|
|
123
|
+
* @param graphMap the one-line type index of the user's readable types.
|
|
124
|
+
* @param domain the app's domain text for the DOMAIN slots.
|
|
125
|
+
* @param catalog the compact descriptions of every type in `graphMap`
|
|
126
|
+
* (`DescribeEntityTool.renderCatalog`). Given, the prompt says the types are
|
|
127
|
+
* already described and describe_entity is not needed for them; absent, the
|
|
128
|
+
* prompt is today's, byte for byte (describe every type first).
|
|
129
|
+
*/
|
|
130
|
+
function renderGraphNodeSystemPrompt(graphMap, domain, catalog) {
|
|
83
131
|
// Function replacements throughout: a string replacement would interpret
|
|
84
132
|
// $&, $`, $' and $n inside app-supplied text and silently mangle the prompt.
|
|
85
|
-
|
|
133
|
+
const base = catalog === undefined ? exports.GRAPH_NODE_SYSTEM_PROMPT_BASE : exports.GRAPH_NODE_SYSTEM_PROMPT_UPFRONT_BASE;
|
|
134
|
+
const rendered = base
|
|
135
|
+
.replace("{GRAPH_MAP}", () => graphMap ||
|
|
86
136
|
"(No accessible data — the user has no enabled modules with described entities. Do not attempt any tool calls. Respond politely explaining that you have no data to query.)")
|
|
87
137
|
.replace("{DOMAIN_ROLE}", () => domain?.role?.trim() || DEFAULT_ROLE)
|
|
88
138
|
.replace("{DOMAIN_DATA_CONVENTIONS}", () => domain?.dataConventions?.trim() ?? "")
|
|
@@ -90,5 +140,8 @@ function renderGraphNodeSystemPrompt(graphMap, domain) {
|
|
|
90
140
|
.replace("{DOMAIN_DEPTH}", () => domain?.depth?.trim() ?? "")
|
|
91
141
|
.replace("{DOMAIN_OUTPUT_RULES}", () => domain?.outputRules?.trim() ?? "")
|
|
92
142
|
.replace(/\n{3,}/g, "\n\n");
|
|
143
|
+
// Filled last, after the blank-line collapse, so the catalog text reaches
|
|
144
|
+
// the model exactly as rendered.
|
|
145
|
+
return catalog === undefined ? rendered : rendered.replace("{GRAPH_CATALOG}", () => catalog.trim());
|
|
93
146
|
}
|
|
94
147
|
//# sourceMappingURL=graph.node.system.prompt.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph.node.system.prompt.js","sourceRoot":"","sources":["../../../../src/agents/graph/prompts/graph.node.system.prompt.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"graph.node.system.prompt.js","sourceRoot":"","sources":["../../../../src/agents/graph/prompts/graph.node.system.prompt.ts"],"names":[],"mappings":";;;AA2HA,kDAGC;AAYD,kEAwBC;AAhKY,QAAA,6BAA6B,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqE5C,CAAC;AAEF;;;;GAIG;AACH,MAAM,sBAAsB,GAAG;;;;mTAIoR,CAAC;AAEpT,uEAAuE;AACvE,MAAM,2BAA2B,GAAG,wPAAwP,CAAC;AAE7R,8HAA8H;AAC9H,MAAM,+BAA+B,GAAG,mgBAAmgB,CAAC;AAE5iB,uGAAuG;AACvG,MAAM,yBAAyB,GAAG,maAAma,CAAC;AAEtc,MAAM,oBAAoB,GAAG,gFAAgF,CAAC;AAC9G,wDAAw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,CAAC;AAED;;;;;;;;;GASG;AACH,SAAgB,2BAA2B,CACzC,QAAgB,EAChB,MAA+B,EAC/B,OAAgB;IAEhB,yEAAyE;IACzE,6EAA6E;IAC7E,MAAM,IAAI,GAAG,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,qCAA6B,CAAC,CAAC,CAAC,6CAAqC,CAAC;IAC3G,MAAM,QAAQ,GAAG,IAAI;SAClB,OAAO,CACN,aAAa,EACb,GAAG,EAAE,CACH,QAAQ;QACR,4KAA4K,CAC/K;SACA,OAAO,CAAC,eAAe,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,YAAY,CAAC;SACpE,OAAO,CAAC,2BAA2B,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;SACjF,OAAO,CAAC,yBAAyB,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;SAC9E,OAAO,CAAC,gBAAgB,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;SAC5D,OAAO,CAAC,uBAAuB,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;SACzE,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IAC9B,0EAA0E;IAC1E,iCAAiC;IACjC,OAAO,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,iBAAiB,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;AACtG,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { FieldKind } from "../../../common/interfaces/entity.schema.interface";
|
|
2
|
+
/** One described field, as `describe_entity` builds it. */
|
|
3
|
+
export interface EntityFieldDescription {
|
|
4
|
+
name: string;
|
|
5
|
+
type: string;
|
|
6
|
+
description: string;
|
|
7
|
+
filterable: boolean;
|
|
8
|
+
sortable: boolean;
|
|
9
|
+
/** Filter operators the field accepts; empty when it cannot be filtered. */
|
|
10
|
+
operators: string[];
|
|
11
|
+
/** The only values the type's service accepts on this field. */
|
|
12
|
+
values?: string[];
|
|
13
|
+
kind?: FieldKind;
|
|
14
|
+
/** Wire format of a richtext field: read and written as markdown. */
|
|
15
|
+
format?: "markdown";
|
|
16
|
+
/** Present only when the type declares a list stage. */
|
|
17
|
+
stage?: "list" | "detail";
|
|
18
|
+
/** Present only when the type is writable. */
|
|
19
|
+
writable?: boolean;
|
|
20
|
+
}
|
|
21
|
+
/** One described relationship, as `describe_entity` builds it. */
|
|
22
|
+
export interface EntityRelationshipDescription {
|
|
23
|
+
name: string;
|
|
24
|
+
/** `"*"` for a polymorphic relationship: each result carries its own type. */
|
|
25
|
+
targetType: string;
|
|
26
|
+
cardinality: "one" | "many";
|
|
27
|
+
description: string;
|
|
28
|
+
/** Present only when the type is writable. */
|
|
29
|
+
writable?: boolean;
|
|
30
|
+
}
|
|
31
|
+
/** A field filled by the type's service on `read_entity` only. */
|
|
32
|
+
export interface EntityDetailFieldDescription {
|
|
33
|
+
name: string;
|
|
34
|
+
type: string;
|
|
35
|
+
description: string;
|
|
36
|
+
availableOn: "read_entity";
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Everything `describe_entity` knows about one type: the structured form that
|
|
40
|
+
* {@link renderCompactDescriptions} turns into text.
|
|
41
|
+
*/
|
|
42
|
+
export interface EntityDescription {
|
|
43
|
+
type: string;
|
|
44
|
+
description: string;
|
|
45
|
+
fields: EntityFieldDescription[];
|
|
46
|
+
relationships: EntityRelationshipDescription[];
|
|
47
|
+
detailFields?: EntityDetailFieldDescription[];
|
|
48
|
+
bridge?: {
|
|
49
|
+
materialiseTo: string[];
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Renders type descriptions as compact text for a model to read. Lossless:
|
|
54
|
+
* every attribute of the structured form survives. Repetition is stated once
|
|
55
|
+
* in a preamble and referenced by name:
|
|
56
|
+
* - a description used two or more times (fields, relationships and detail
|
|
57
|
+
* fields alike) becomes a shared entry `D<n>`;
|
|
58
|
+
* - each distinct filter-operator list becomes `O<n>`; a field that cannot be
|
|
59
|
+
* filtered shows none;
|
|
60
|
+
* - flags appear only where they differ from the defaults the guide states.
|
|
61
|
+
*
|
|
62
|
+
* Entry names are numbered in content order, never input order, so a type's
|
|
63
|
+
* block does not change when the input is reordered. The type blocks keep the
|
|
64
|
+
* input order. Same input, same text.
|
|
65
|
+
*
|
|
66
|
+
* `standalone: true` (one `describe_entity` result) prints only the guide
|
|
67
|
+
* lines the given types use; `standalone: false` (a catalog of many types)
|
|
68
|
+
* prints the whole guide (bar the lines for marks the builder never produces),
|
|
69
|
+
* so the conventions read the same whatever types a user can see. The shared
|
|
70
|
+
* entries are always exactly those the given types reference, so the output
|
|
71
|
+
* never refers to a part it does not define.
|
|
72
|
+
*/
|
|
73
|
+
export declare function renderCompactDescriptions(descriptions: EntityDescription[], options: {
|
|
74
|
+
standalone: boolean;
|
|
75
|
+
}): string;
|
|
76
|
+
//# sourceMappingURL=compact-description.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compact-description.d.ts","sourceRoot":"","sources":["../../../../src/agents/graph/services/compact-description.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oDAAoD,CAAC;AAEpF,2DAA2D;AAC3D,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;IAClB,4EAA4E;IAC5E,SAAS,EAAE,MAAM,EAAE,CAAC;IAC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
|
|
3
|
+
exports.renderCompactDescriptions = renderCompactDescriptions;
|
|
4
|
+
/**
|
|
5
|
+
* Shorter descriptions stay inline even when repeated: a reference to the
|
|
6
|
+
* shared entry would save next to nothing and cost the reader a lookup.
|
|
7
|
+
*/
|
|
8
|
+
const MIN_SHARED_DESCRIPTION_LENGTH = 20;
|
|
9
|
+
/** The reading guide, one entry per convention. Order is the printed order. */
|
|
10
|
+
const GUIDE = {
|
|
11
|
+
lines: "Fields: name (type) [marks]: description. Relationships: name -> target type (one or many) [marks]: description.",
|
|
12
|
+
shared: "see Dn: the shared description Dn below.",
|
|
13
|
+
filter: "filter On: filterable with the operators of list On below. No filter mark: not filterable.",
|
|
14
|
+
filterOdd: "filterable, no operators: counts as filterable but accepts no operator. not filterable, operators On: lists operators yet is not filterable.",
|
|
15
|
+
sort: "Filterable fields are sortable unless marked no sort; other fields are not sortable unless marked sort.",
|
|
16
|
+
values: "values [...]: the only values accepted.",
|
|
17
|
+
money: "money(N): an integer in minor units with N decimals (divide by 10^N to display); plain money: 2 decimals.",
|
|
18
|
+
richtext: "richtext: rich text. markdown: read and written as markdown.",
|
|
19
|
+
list: "list stage (on a type): search_entities and traverse return only the fields marked list; read_entity returns all.",
|
|
20
|
+
writable: "writable (on a type): the write tools may set only the fields and relationships marked writable.",
|
|
21
|
+
polymorphic: "-> *: records of any type; each result carries its own type.",
|
|
22
|
+
detail: "Detail fields: returned only by the tool in their heading; never filtered, sorted, searched or listed.",
|
|
23
|
+
bridge: "Bridge, materialiseTo: a junction type; its reads inline the targets of the named relationships.",
|
|
24
|
+
};
|
|
25
|
+
/** Guide lines for marks the description builder never produces today: printed only when a type uses them. */
|
|
26
|
+
const ONLY_WHEN_USED = new Set(["filterOdd"]);
|
|
27
|
+
/** Code-unit order: identical on every machine, whatever the locale. */
|
|
28
|
+
const byCodeUnit = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
|
|
29
|
+
const isWritableType = (d) => d.fields.some((f) => f.writable !== undefined) || d.relationships.some((r) => r.writable !== undefined);
|
|
30
|
+
const hasListStage = (d) => d.fields.some((f) => f.stage !== undefined);
|
|
31
|
+
function moneyMark(kind) {
|
|
32
|
+
return kind.type === "money" && kind.minorUnits !== undefined ? `money(${kind.minorUnits})` : "money";
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Renders type descriptions as compact text for a model to read. Lossless:
|
|
36
|
+
* every attribute of the structured form survives. Repetition is stated once
|
|
37
|
+
* in a preamble and referenced by name:
|
|
38
|
+
* - a description used two or more times (fields, relationships and detail
|
|
39
|
+
* fields alike) becomes a shared entry `D<n>`;
|
|
40
|
+
* - each distinct filter-operator list becomes `O<n>`; a field that cannot be
|
|
41
|
+
* filtered shows none;
|
|
42
|
+
* - flags appear only where they differ from the defaults the guide states.
|
|
43
|
+
*
|
|
44
|
+
* Entry names are numbered in content order, never input order, so a type's
|
|
45
|
+
* block does not change when the input is reordered. The type blocks keep the
|
|
46
|
+
* input order. Same input, same text.
|
|
47
|
+
*
|
|
48
|
+
* `standalone: true` (one `describe_entity` result) prints only the guide
|
|
49
|
+
* lines the given types use; `standalone: false` (a catalog of many types)
|
|
50
|
+
* prints the whole guide (bar the lines for marks the builder never produces),
|
|
51
|
+
* so the conventions read the same whatever types a user can see. The shared
|
|
52
|
+
* entries are always exactly those the given types reference, so the output
|
|
53
|
+
* never refers to a part it does not define.
|
|
54
|
+
*/
|
|
55
|
+
function renderCompactDescriptions(descriptions, options) {
|
|
56
|
+
// Shared descriptions: counted across every described part of every type.
|
|
57
|
+
const counts = new Map();
|
|
58
|
+
const count = (text) => {
|
|
59
|
+
if (text.length >= MIN_SHARED_DESCRIPTION_LENGTH)
|
|
60
|
+
counts.set(text, (counts.get(text) ?? 0) + 1);
|
|
61
|
+
};
|
|
62
|
+
for (const d of descriptions) {
|
|
63
|
+
for (const f of d.fields)
|
|
64
|
+
count(f.description);
|
|
65
|
+
for (const r of d.relationships)
|
|
66
|
+
count(r.description);
|
|
67
|
+
for (const f of d.detailFields ?? [])
|
|
68
|
+
count(f.description);
|
|
69
|
+
}
|
|
70
|
+
const sharedTexts = [...counts.entries()]
|
|
71
|
+
.filter(([, n]) => n >= 2)
|
|
72
|
+
.map(([text]) => text)
|
|
73
|
+
.sort(byCodeUnit);
|
|
74
|
+
const sharedId = new Map(sharedTexts.map((text, i) => [text, `D${i + 1}`]));
|
|
75
|
+
const operatorLists = [
|
|
76
|
+
...new Set(descriptions.flatMap((d) => d.fields.filter((f) => f.operators.length).map((f) => f.operators.join(", ")))),
|
|
77
|
+
].sort(byCodeUnit);
|
|
78
|
+
const operatorId = new Map(operatorLists.map((list, i) => [list, `O${i + 1}`]));
|
|
79
|
+
const used = new Set(["lines", "sort"]);
|
|
80
|
+
const describe = (text) => {
|
|
81
|
+
const id = sharedId.get(text);
|
|
82
|
+
if (!id)
|
|
83
|
+
return text;
|
|
84
|
+
used.add("shared");
|
|
85
|
+
return `see ${id}`;
|
|
86
|
+
};
|
|
87
|
+
const tail = (marks, text) => `${marks.length ? ` [${marks.join(", ")}]` : ""}${text ? `: ${describe(text)}` : ""}`;
|
|
88
|
+
const blocks = descriptions.map((d) => {
|
|
89
|
+
const writableType = isWritableType(d);
|
|
90
|
+
const listStage = hasListStage(d);
|
|
91
|
+
const typeMarks = [];
|
|
92
|
+
if (writableType) {
|
|
93
|
+
typeMarks.push("writable");
|
|
94
|
+
used.add("writable");
|
|
95
|
+
}
|
|
96
|
+
if (listStage) {
|
|
97
|
+
typeMarks.push("list stage");
|
|
98
|
+
used.add("list");
|
|
99
|
+
}
|
|
100
|
+
const lines = [`## ${d.type}${typeMarks.length ? ` [${typeMarks.join(", ")}]` : ""}`];
|
|
101
|
+
if (d.description)
|
|
102
|
+
lines.push(d.description);
|
|
103
|
+
if (d.bridge) {
|
|
104
|
+
lines.push(`Bridge, materialiseTo: ${d.bridge.materialiseTo.join(", ")}`);
|
|
105
|
+
used.add("bridge");
|
|
106
|
+
}
|
|
107
|
+
if (d.fields.length) {
|
|
108
|
+
lines.push("Fields:");
|
|
109
|
+
for (const f of d.fields) {
|
|
110
|
+
const marks = [];
|
|
111
|
+
const ops = f.operators.length ? operatorId.get(f.operators.join(", ")) : undefined;
|
|
112
|
+
if (f.filterable && ops) {
|
|
113
|
+
marks.push(`filter ${ops}`);
|
|
114
|
+
used.add("filter");
|
|
115
|
+
}
|
|
116
|
+
else if (f.filterable || ops) {
|
|
117
|
+
// Unreachable from describe_entity today; kept so the form stays lossless.
|
|
118
|
+
marks.push(f.filterable ? "filterable, no operators" : `not filterable, operators ${ops}`);
|
|
119
|
+
used.add("filterOdd");
|
|
120
|
+
}
|
|
121
|
+
// Default: sortable exactly when filterable. Only exceptions are marked.
|
|
122
|
+
if (f.filterable && !f.sortable)
|
|
123
|
+
marks.push("no sort");
|
|
124
|
+
if (!f.filterable && f.sortable)
|
|
125
|
+
marks.push("sort");
|
|
126
|
+
if (f.values?.length) {
|
|
127
|
+
marks.push(`values ${JSON.stringify(f.values)}`);
|
|
128
|
+
used.add("values");
|
|
129
|
+
}
|
|
130
|
+
if (f.kind?.type === "money") {
|
|
131
|
+
marks.push(moneyMark(f.kind));
|
|
132
|
+
used.add("money");
|
|
133
|
+
}
|
|
134
|
+
if (f.kind?.type === "richtext") {
|
|
135
|
+
marks.push("richtext");
|
|
136
|
+
used.add("richtext");
|
|
137
|
+
}
|
|
138
|
+
if (f.format === "markdown") {
|
|
139
|
+
marks.push("markdown");
|
|
140
|
+
used.add("richtext");
|
|
141
|
+
}
|
|
142
|
+
if (f.stage === "list")
|
|
143
|
+
marks.push("list");
|
|
144
|
+
if (f.writable)
|
|
145
|
+
marks.push("writable");
|
|
146
|
+
lines.push(`- ${f.name} (${f.type})${tail(marks, f.description)}`);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
if (d.relationships.length) {
|
|
150
|
+
lines.push("Relationships:");
|
|
151
|
+
for (const r of d.relationships) {
|
|
152
|
+
if (r.targetType === "*")
|
|
153
|
+
used.add("polymorphic");
|
|
154
|
+
lines.push(`- ${r.name} -> ${r.targetType} (${r.cardinality})${tail(r.writable ? ["writable"] : [], r.description)}`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (d.detailFields?.length) {
|
|
158
|
+
used.add("detail");
|
|
159
|
+
const where = [...new Set(d.detailFields.map((f) => f.availableOn))].sort(byCodeUnit).join(", ");
|
|
160
|
+
lines.push(`Detail fields, ${where} only:`);
|
|
161
|
+
for (const f of d.detailFields)
|
|
162
|
+
lines.push(`- ${f.name} (${f.type})${tail([], f.description)}`);
|
|
163
|
+
}
|
|
164
|
+
return lines.join("\n");
|
|
165
|
+
});
|
|
166
|
+
const guide = Object.keys(GUIDE)
|
|
167
|
+
.filter((key) => used.has(key) || (!options.standalone && !ONLY_WHEN_USED.has(key)))
|
|
168
|
+
.map((key) => `- ${GUIDE[key]}`);
|
|
169
|
+
const preamble = ["How to read the type descriptions:", ...guide];
|
|
170
|
+
if (operatorLists.length) {
|
|
171
|
+
preamble.push("Operator lists:", ...operatorLists.map((list) => `- ${operatorId.get(list)}: ${list}`));
|
|
172
|
+
}
|
|
173
|
+
if (sharedTexts.length) {
|
|
174
|
+
preamble.push("Shared descriptions:", ...sharedTexts.map((text) => `- ${sharedId.get(text)}: ${text}`));
|
|
175
|
+
}
|
|
176
|
+
return [preamble.join("\n"), ...blocks].join("\n\n");
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=compact-description.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compact-description.js","sourceRoot":"","sources":["../../../../src/agents/graph/services/compact-description.ts"],"names":[],"mappings":";;AAqHA,8DAyHC;AAxLD;;;GAGG;AACH,MAAM,6BAA6B,GAAG,EAAE,CAAC;AAEzC,+EAA+E;AAC/E,MAAM,KAAK,GAAG;IACZ,KAAK,EACH,kHAAkH;IACpH,MAAM,EAAE,0CAA0C;IAClD,MAAM,EAAE,4FAA4F;IACpG,SAAS,EACP,8IAA8I;IAChJ,IAAI,EAAE,yGA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,WAAW,CAAC,MAAM,EAAE,CAAC;QACvB,QAAQ,CAAC,IAAI,CAAC,sBAAsB,EAAE,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC;IAC1G,CAAC;IACD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AACvD,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CatalogField } from "../interfaces/graph.catalog.interface";
|
|
2
|
+
import type { ExternalFilterCapability } from "../../../common/interfaces/external.entity.source.interface";
|
|
3
|
+
/** Operators valid for each catalog field type. A type missing here accepts no operator. */
|
|
4
|
+
export declare const TYPE_TO_OP_ALLOWED: Record<string, Set<string>>;
|
|
5
|
+
/**
|
|
6
|
+
* The filter capabilities a type's service declares, or `undefined` when it
|
|
7
|
+
* declares none (records in the app database: the type table applies).
|
|
8
|
+
*/
|
|
9
|
+
export declare function serviceFilterCapabilities(svc: unknown): ExternalFilterCapability[] | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* The operators a filter on `field` may use. When the service declares
|
|
12
|
+
* capabilities they win over the type table: exactly the operators listed for
|
|
13
|
+
* the field, none when it is not listed. Otherwise the operators of the field's type.
|
|
14
|
+
*/
|
|
15
|
+
export declare function allowedFilterOperators(field: CatalogField, capabilities: ExternalFilterCapability[] | undefined): string[];
|
|
16
|
+
//# sourceMappingURL=filter-operators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter-operators.d.ts","sourceRoot":"","sources":["../../../../src/agents/graph/services/filter-operators.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,KAAK,EAEV,wBAAwB,EACzB,MAAM,6DAA6D,CAAC;AAMrE,4FAA4F;AAC5F,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAM1D,CAAC;AAEF;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,OAAO,GAAG,wBAAwB,EAAE,GAAG,SAAS,CAG9F;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,YAAY,EACnB,YAAY,EAAE,wBAAwB,EAAE,GAAG,SAAS,GACnD,MAAM,EAAE,CAGV"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TYPE_TO_OP_ALLOWED = void 0;
|
|
4
|
+
exports.serviceFilterCapabilities = serviceFilterCapabilities;
|
|
5
|
+
exports.allowedFilterOperators = allowedFilterOperators;
|
|
6
|
+
// Lives apart from traverse.tool so describe_entity's description builder can
|
|
7
|
+
// use it and traverse.tool can import that builder without an import cycle.
|
|
8
|
+
// traverse.tool re-exports everything here.
|
|
9
|
+
/** Operators valid for each catalog field type. A type missing here accepts no operator. */
|
|
10
|
+
exports.TYPE_TO_OP_ALLOWED = {
|
|
11
|
+
string: new Set(["eq", "ne", "in", "like", "isNull", "isNotNull"]),
|
|
12
|
+
number: new Set(["eq", "ne", "in", "gt", "gte", "lt", "lte", "isNull", "isNotNull"]),
|
|
13
|
+
boolean: new Set(["eq", "ne", "isNull", "isNotNull"]),
|
|
14
|
+
date: new Set(["eq", "ne", "gt", "gte", "lt", "lte", "isNull", "isNotNull"]),
|
|
15
|
+
datetime: new Set(["eq", "ne", "gt", "gte", "lt", "lte", "isNull", "isNotNull"]),
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* The filter capabilities a type's service declares, or `undefined` when it
|
|
19
|
+
* declares none (records in the app database: the type table applies).
|
|
20
|
+
*/
|
|
21
|
+
function serviceFilterCapabilities(svc) {
|
|
22
|
+
const hook = svc?.filterCapabilities;
|
|
23
|
+
return typeof hook === "function" ? hook.call(svc) : undefined;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The operators a filter on `field` may use. When the service declares
|
|
27
|
+
* capabilities they win over the type table: exactly the operators listed for
|
|
28
|
+
* the field, none when it is not listed. Otherwise the operators of the field's type.
|
|
29
|
+
*/
|
|
30
|
+
function allowedFilterOperators(field, capabilities) {
|
|
31
|
+
if (capabilities)
|
|
32
|
+
return [...(capabilities.find((c) => c.field === field.name)?.operators ?? [])];
|
|
33
|
+
return Array.from(exports.TYPE_TO_OP_ALLOWED[field.type] ?? []);
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=filter-operators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter-operators.js","sourceRoot":"","sources":["../../../../src/agents/graph/services/filter-operators.ts"],"names":[],"mappings":";;;AAuBA,8DAGC;AAOD,wDAMC;AAjCD,8EAA8E;AAC9E,4EAA4E;AAC5E,4CAA4C;AAE5C,4FAA4F;AAC/E,QAAA,kBAAkB,GAAgC;IAC7D,MAAM,EAAE,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;IAClE,MAAM,EAAE,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;IACpF,OAAO,EAAE,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;IACrD,IAAI,EAAE,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;IAC5E,QAAQ,EAAE,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;CACjF,CAAC;AAEF;;;GAGG;AACH,SAAgB,yBAAyB,CAAC,GAAY;IACpD,MAAM,IAAI,GAAI,GAAiD,EAAE,kBAAkB,CAAC;IACpF,OAAO,OAAO,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACjE,CAAC;AAED;;;;GAIG;AACH,SAAgB,sBAAsB,CACpC,KAAmB,EACnB,YAAoD;IAEpD,IAAI,YAAY;QAAE,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,IAAI,CAAC,EAAE,SAAS,IAAI,EAAE,CAAC,CAAC,CAAC;IAClG,OAAO,KAAK,CAAC,IAAI,CAAC,0BAAkB,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;AAC1D,CAAC"}
|
|
@@ -1,14 +1,70 @@
|
|
|
1
1
|
import { DynamicStructuredTool } from "@langchain/core/tools";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { ToolFactory, ToolCallRecord, UserContext } from "./tool.factory";
|
|
4
|
+
import { EntityDescription } from "../services/compact-description";
|
|
5
|
+
import type { CatalogEntity } from "../interfaces/graph.catalog.interface";
|
|
6
|
+
import type { ExternalFilterCapability } from "../../../common/interfaces/external.entity.source.interface";
|
|
4
7
|
declare const inputSchema: z.ZodObject<{
|
|
5
8
|
type: z.ZodString;
|
|
6
9
|
}, z.core.$strip>;
|
|
7
10
|
export { inputSchema as describeEntityInputSchema };
|
|
11
|
+
/**
|
|
12
|
+
* The structured description of one catalog type: what the model may filter,
|
|
13
|
+
* sort, read and write on it. `capabilities` are the filter capabilities of the
|
|
14
|
+
* type's service (`serviceFilterCapabilities`), `undefined` when it declares none.
|
|
15
|
+
* Shared by `describe_entity` and the describe-first refusals of the read tools,
|
|
16
|
+
* so both show the same contract.
|
|
17
|
+
*/
|
|
18
|
+
export declare function describeCatalogEntity(entity: CatalogEntity, capabilities: ExternalFilterCapability[] | undefined): EntityDescription;
|
|
19
|
+
/**
|
|
20
|
+
* The compact, standalone schema text of one catalog type, exactly as
|
|
21
|
+
* `describe_entity` returns it. `service` is the type's registered service
|
|
22
|
+
* (its filter capabilities decide the operators). Carried by the describe-first
|
|
23
|
+
* refusals of read_entity, search_entities and traverse.
|
|
24
|
+
*/
|
|
25
|
+
export declare function renderEntitySchema(entity: CatalogEntity, service: unknown): string;
|
|
26
|
+
/** What `describe_entity` returns for a known type: the compact, self-contained text form. */
|
|
27
|
+
export interface DescribeEntityResult {
|
|
28
|
+
type: string;
|
|
29
|
+
/** `renderCompactDescriptions([description], { standalone: true })`. */
|
|
30
|
+
schema: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The `describe_entity` tool: the fields, relationships, filter operators and
|
|
34
|
+
* writable parts of one entity type, returned as `{ type, schema }` where
|
|
35
|
+
* `schema` is the compact text of {@link renderCompactDescriptions} rendered
|
|
36
|
+
* standalone (it defines every shared part it refers to). An unknown or
|
|
37
|
+
* inaccessible type returns the factory's `{ error, suggestion? }` object.
|
|
38
|
+
*
|
|
39
|
+
* {@link DescribeEntityTool.buildDescription} returns the structured form, for
|
|
40
|
+
* callers that render several types together.
|
|
41
|
+
*/
|
|
8
42
|
export declare class DescribeEntityTool {
|
|
9
43
|
private readonly factory;
|
|
10
44
|
constructor(factory: ToolFactory);
|
|
11
45
|
build(ctx: UserContext, recorder: ToolCallRecord[]): DynamicStructuredTool;
|
|
12
|
-
|
|
46
|
+
/** The structured description of `type` for this user, or the factory's error object. */
|
|
47
|
+
buildDescription(type: string, ctx: UserContext): EntityDescription | {
|
|
48
|
+
error: string;
|
|
49
|
+
suggestion?: string;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* The compact catalog of every type this user can read, for a caller that
|
|
53
|
+
* gives the model all descriptions up front (the responder lookup). Types are
|
|
54
|
+
* sorted by name and rendered together with `{ standalone: false }`, so the
|
|
55
|
+
* text depends only on `ctx.userModuleIds` and is byte-identical across
|
|
56
|
+
* calls for the same modules. `types` lists the rendered types (the
|
|
57
|
+
* pre-described set of {@link UserContext.preDescribedTypes});
|
|
58
|
+
* `approxTokens` is `Math.ceil(text.length / 4)`.
|
|
59
|
+
*/
|
|
60
|
+
renderCatalog(ctx: UserContext): {
|
|
61
|
+
text: string;
|
|
62
|
+
types: string[];
|
|
63
|
+
approxTokens: number;
|
|
64
|
+
};
|
|
65
|
+
invoke(input: z.infer<typeof inputSchema>, ctx: UserContext, recorder: ToolCallRecord[]): Promise<DescribeEntityResult | {
|
|
66
|
+
error: string;
|
|
67
|
+
suggestion?: string;
|
|
68
|
+
}>;
|
|
13
69
|
}
|
|
14
70
|
//# sourceMappingURL=describe-entity.tool.d.ts.map
|