@jangts/agent-core 0.3.6 → 0.5.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/CHANGELOG.md +20 -0
- package/README.md +5 -5
- package/development/docs/README.en.md +2 -2
- package/development/docs/acceptance.en.md +2 -2
- package/development/docs/agent-development.en.md +1 -1
- package/development/docs/api/README.en.md +4 -2
- package/development/docs/api/README.md +2 -0
- package/development/docs/api/configuration-in-workflow.en.md +403 -0
- package/development/docs/api/configuration-in-workflow.md +403 -0
- package/development/docs/api/core.en.md +7 -7
- package/development/docs/api/core.md +6 -6
- package/development/docs/api/decorators.en.md +20 -0
- package/development/docs/api/decorators.md +20 -0
- package/development/docs/api/examples.en.md +1 -1
- package/development/docs/api/examples.md +1 -1
- package/development/docs/api/kits.en.md +22 -4
- package/development/docs/api/kits.md +22 -4
- package/development/docs/api/knowledge-answering.en.md +4 -1
- package/development/docs/api/knowledge-answering.md +4 -1
- package/development/docs/api/mock.en.md +2 -0
- package/development/docs/api/mock.md +2 -0
- package/development/docs/api/reference.en.md +508 -410
- package/development/docs/api/reference.md +508 -410
- package/development/docs/api/support.en.md +55 -9
- package/development/docs/api/support.md +53 -7
- package/development/docs/api/types.en.md +35 -1
- package/development/docs/api/types.md +43 -0
- package/development/docs/basic-usage.en.md +1 -1
- package/development/docs/basic-usage.md +1 -1
- package/development/docs/create-app.en.md +1 -1
- package/development/docs/examples/registration/associated.mjs +8 -0
- package/development/docs/examples/registration/independent.mjs +20 -0
- package/development/docs/examples/registration/protocol.mjs +48 -0
- package/development/docs/examples/registration/run.mjs +47 -0
- package/development/docs/examples/registration/tools.mjs +75 -0
- package/development/docs/examples/registration/workflow.mjs +109 -0
- package/development/docs/flows/knowledge-maintenance.en.md +1 -1
- package/development/docs/materials.en.md +1 -1
- package/development/docs/mechanisms.en.md +2 -2
- package/development/docs/mechanisms.md +1 -1
- package/development/docs/operations.en.md +1 -1
- package/development/docs/records.en.md +1 -1
- package/development/docs/registration.en.md +4 -4
- package/development/docs/registration.md +2 -2
- package/development/skills/agent-core-app/SKILL.md +4 -4
- package/development/skills/agent-core-app/templates/node-ts/README.md.tpl +1 -1
- package/development/skills/agent-core-app/templates/node-ts/src/catalog.ts.tpl +2 -2
- package/development/skills/agent-core-app/templates/node-ts/test/app.test.mjs.tpl +1 -1
- package/dist/cjs/capabilities/index.js +5 -12
- package/dist/cjs/capabilities/model.js +56 -12
- package/dist/cjs/capabilities/tool-conditions.js +65 -0
- package/dist/cjs/capabilities/tool-runtime.js +10 -3
- package/dist/cjs/context/audit.js +5 -8
- package/dist/cjs/context/index.js +3 -4
- package/dist/cjs/index.js +21 -17
- package/dist/cjs/kits/answering/tasks.js +5 -5
- package/dist/cjs/kits/domains/catalog.js +113 -0
- package/dist/cjs/kits/domains/index.js +20 -0
- package/dist/cjs/kits/{intents → domains}/registry.js +77 -31
- package/dist/cjs/kits/{intents → domains}/scopes.js +21 -21
- package/dist/cjs/kits/index.js +14 -13
- package/dist/cjs/kits/presentation/formats.js +110 -0
- package/dist/cjs/kits/presentation/index.js +10 -5
- package/dist/cjs/kits/reflection.js +2 -2
- package/dist/cjs/kits/text-blocks.js +101 -0
- package/dist/cjs/kits/tools.js +246 -158
- package/dist/cjs/model/index.js +2 -6
- package/dist/cjs/model/interactions/calls.js +61 -0
- package/dist/cjs/model/interactions/json-object.js +11 -11
- package/dist/cjs/model/interactions/native-functions.js +17 -23
- package/dist/cjs/model/message-diagnostics.js +13 -3
- package/dist/cjs/model/options.js +2 -0
- package/dist/cjs/model/preparation.js +39 -6
- package/dist/cjs/model/runner.js +14 -0
- package/dist/cjs/model/selection-transport.js +4 -4
- package/dist/cjs/model/token-budget.js +3 -0
- package/dist/cjs/model/transports.js +3 -2
- package/dist/cjs/structs/index.js +7 -6
- package/dist/cjs/structs/kits/presentation/formats.js +2 -0
- package/dist/cjs/structs/kits/text-blocks.js +11 -0
- package/dist/cjs/structs/model/session.js +11 -0
- package/dist/cjs/structs/support/associations.js +2 -0
- package/dist/cjs/support/associations.js +79 -0
- package/dist/cjs/support/context/snapshot.js +11 -1
- package/dist/cjs/support/decorators/index.js +45 -3
- package/dist/cjs/support/index.js +1 -0
- package/dist/cjs/support/model/capabilities.js +35 -5
- package/dist/cjs/support/model/chat-completions.js +11 -2
- package/dist/cjs/support/model/completion/calls.js +10 -56
- package/dist/cjs/support/model/preview-rules.js +11 -11
- package/dist/cjs/support/model/reply-preview.js +3 -3
- package/dist/cjs/support/model/session.js +152 -0
- package/dist/cjs/support/model/stage-transport.js +8 -8
- package/dist/cjs/support/model/transports.js +5 -2
- package/dist/cjs/support/tools.js +42 -17
- package/dist/esm/capabilities/index.d.ts +5 -10
- package/dist/esm/capabilities/index.js +5 -9
- package/dist/esm/capabilities/model.d.ts +17 -13
- package/dist/esm/capabilities/model.js +54 -10
- package/dist/esm/capabilities/tool-conditions.d.ts +9 -0
- package/dist/esm/capabilities/tool-conditions.js +59 -0
- package/dist/esm/capabilities/tool-runtime.js +10 -3
- package/dist/esm/capabilities/tools.d.ts +3 -3
- package/dist/esm/context/audit.js +5 -8
- package/dist/esm/context/index.d.ts +3 -4
- package/dist/esm/context/index.js +3 -4
- package/dist/esm/index.d.ts +19 -13
- package/dist/esm/index.js +18 -15
- package/dist/esm/kits/answering/tasks.d.ts +6 -6
- package/dist/esm/kits/answering/tasks.js +5 -5
- package/dist/esm/kits/domains/catalog.d.ts +42 -0
- package/dist/esm/kits/domains/catalog.js +110 -0
- package/dist/esm/kits/domains/index.d.ts +4 -0
- package/dist/esm/kits/domains/index.js +4 -0
- package/dist/esm/kits/domains/registry.d.ts +100 -0
- package/dist/esm/kits/{intents → domains}/registry.js +77 -31
- package/dist/esm/kits/{intents → domains}/scopes.d.ts +18 -18
- package/dist/esm/kits/{intents → domains}/scopes.js +21 -21
- package/dist/esm/kits/index.d.ts +6 -5
- package/dist/esm/kits/index.js +6 -5
- package/dist/esm/kits/presentation/formats.d.ts +42 -0
- package/dist/esm/kits/presentation/formats.js +105 -0
- package/dist/esm/kits/presentation/index.d.ts +14 -5
- package/dist/esm/kits/presentation/index.js +10 -5
- package/dist/esm/kits/reflection.js +3 -3
- package/dist/esm/kits/text-blocks.d.ts +24 -0
- package/dist/esm/kits/text-blocks.js +97 -0
- package/dist/esm/kits/tools.d.ts +69 -52
- package/dist/esm/kits/tools.js +246 -158
- package/dist/esm/model/index.d.ts +2 -6
- package/dist/esm/model/index.js +2 -6
- package/dist/esm/model/interactions/calls.d.ts +40 -0
- package/dist/esm/model/interactions/calls.js +58 -0
- package/dist/esm/model/interactions/json-object.js +11 -11
- package/dist/esm/model/interactions/native-functions.js +17 -23
- package/dist/esm/model/message-diagnostics.d.ts +6 -5
- package/dist/esm/model/message-diagnostics.js +13 -3
- package/dist/esm/model/options.js +2 -0
- package/dist/esm/model/preparation.js +39 -6
- package/dist/esm/model/runner.js +14 -0
- package/dist/esm/model/selection-transport.js +4 -4
- package/dist/esm/model/token-budget.js +3 -0
- package/dist/esm/model/transports.d.ts +2 -1
- package/dist/esm/model/transports.js +3 -2
- package/dist/esm/structs/capabilities/invocation.d.ts +1 -1
- package/dist/esm/structs/capabilities/model.d.ts +42 -11
- package/dist/esm/structs/capabilities/tools.d.ts +9 -4
- package/dist/esm/structs/common.d.ts +1 -1
- package/dist/esm/structs/index.d.ts +7 -6
- package/dist/esm/structs/index.js +7 -6
- package/dist/esm/structs/kits/answering/tasks.d.ts +2 -2
- package/dist/esm/structs/kits/{intents → domains}/catalog.d.ts +20 -20
- package/dist/esm/structs/kits/{intents → domains}/registry.d.ts +24 -21
- package/dist/esm/structs/kits/{intents → domains}/scopes.d.ts +9 -9
- package/dist/esm/structs/kits/presentation/formats.d.ts +42 -0
- package/dist/esm/structs/kits/presentation/formats.js +1 -0
- package/dist/esm/structs/kits/text-blocks.d.ts +25 -0
- package/dist/esm/structs/kits/text-blocks.js +10 -0
- package/dist/esm/structs/kits/tools.d.ts +82 -83
- package/dist/esm/structs/model/interactions.d.ts +18 -11
- package/dist/esm/structs/model/messages.d.ts +34 -2
- package/dist/esm/structs/model/runtime.d.ts +7 -0
- package/dist/esm/structs/model/session.d.ts +29 -0
- package/dist/esm/structs/model/session.js +10 -0
- package/dist/esm/structs/support/associations.d.ts +22 -0
- package/dist/esm/structs/support/associations.js +1 -0
- package/dist/esm/structs/support/model/interactions.d.ts +2 -2
- package/dist/esm/structs/support/model/messages.d.ts +6 -13
- package/dist/esm/structs/support/tools.d.ts +23 -23
- package/dist/esm/support/associations.d.ts +26 -0
- package/dist/esm/support/associations.js +76 -0
- package/dist/esm/support/context/snapshot.js +11 -1
- package/dist/esm/support/decorators/index.d.ts +13 -2
- package/dist/esm/support/decorators/index.js +40 -3
- package/dist/esm/support/decorators/pool.d.ts +6 -5
- package/dist/esm/support/decorators/types.d.ts +3 -1
- package/dist/esm/support/index.d.ts +1 -0
- package/dist/esm/support/index.js +1 -0
- package/dist/esm/support/model/capabilities.d.ts +8 -3
- package/dist/esm/support/model/capabilities.js +35 -5
- package/dist/esm/support/model/chat-completions.js +11 -2
- package/dist/esm/support/model/completion/calls.d.ts +6 -34
- package/dist/esm/support/model/completion/calls.js +8 -55
- package/dist/esm/support/model/index.d.ts +1 -1
- package/dist/esm/support/model/preview-rules.d.ts +13 -8
- package/dist/esm/support/model/preview-rules.js +11 -11
- package/dist/esm/support/model/reply-preview.d.ts +2 -2
- package/dist/esm/support/model/reply-preview.js +3 -3
- package/dist/esm/support/model/session.d.ts +61 -0
- package/dist/esm/support/model/session.js +148 -0
- package/dist/esm/support/model/stage-transport.d.ts +1 -1
- package/dist/esm/support/model/stage-transport.js +9 -9
- package/dist/esm/support/model/transports.d.ts +2 -0
- package/dist/esm/support/model/transports.js +2 -1
- package/dist/esm/support/tools.d.ts +11 -3
- package/dist/esm/support/tools.js +43 -18
- package/dist/esm/utils/catalog.d.ts +1 -1
- package/package.json +20 -6
- package/dist/cjs/execution/index.js +0 -30
- package/dist/cjs/kits/intents/catalog.js +0 -82
- package/dist/cjs/kits/intents/index.js +0 -35
- package/dist/esm/execution/index.d.ts +0 -11
- package/dist/esm/execution/index.js +0 -11
- package/dist/esm/kits/intents/catalog.d.ts +0 -39
- package/dist/esm/kits/intents/catalog.js +0 -79
- package/dist/esm/kits/intents/index.d.ts +0 -22
- package/dist/esm/kits/intents/index.js +0 -18
- package/dist/esm/kits/intents/registry.d.ts +0 -88
- /package/dist/cjs/structs/kits/{intents → domains}/catalog.js +0 -0
- /package/dist/cjs/structs/kits/{intents → domains}/registry.js +0 -0
- /package/dist/cjs/structs/kits/{intents → domains}/scopes.js +0 -0
- /package/dist/esm/structs/kits/{intents → domains}/catalog.js +0 -0
- /package/dist/esm/structs/kits/{intents → domains}/registry.js +0 -0
- /package/dist/esm/structs/kits/{intents → domains}/scopes.js +0 -0
|
@@ -22,15 +22,14 @@ exports.assembleContextPlan = exports.assembleFragments = void 0;
|
|
|
22
22
|
* Core owns the guarantees here. A fragment declares its trust, lifetime and character
|
|
23
23
|
* budget in one place; assembly validates those declarations and refuses to truncate;
|
|
24
24
|
* auditing rejects structural change to protected fragments. Selection, ordering, compression
|
|
25
|
-
* and model choice remain App-side nodes that run before this boundary.
|
|
25
|
+
* and model choice remain App-side nodes that run before this boundary. Optional Kit helpers
|
|
26
|
+
* such as evidence checks are imported from their own `/kits/*` entries, not from here.
|
|
26
27
|
*
|
|
27
|
-
* Exports: `assembleFragments`, `assembleContextPlan`, `ContextJournal
|
|
28
|
-
* and the evidence Kit helpers consumed alongside assembled context.
|
|
28
|
+
* Exports: `assembleFragments`, `assembleContextPlan`, `ContextJournal` and the fragment helpers.
|
|
29
29
|
*/
|
|
30
30
|
__exportStar(require("./fragments.js"), exports);
|
|
31
31
|
var assembly_js_1 = require("./assembly.js");
|
|
32
32
|
Object.defineProperty(exports, "assembleFragments", { enumerable: true, get: function () { return assembly_js_1.assembleFragments; } });
|
|
33
33
|
__exportStar(require("./journal.js"), exports);
|
|
34
|
-
__exportStar(require("../kits/evidence.js"), exports);
|
|
35
34
|
var plan_js_1 = require("./plan.js");
|
|
36
35
|
Object.defineProperty(exports, "assembleContextPlan", { enumerable: true, get: function () { return plan_js_1.assembleContextPlan; } });
|
package/dist/cjs/index.js
CHANGED
|
@@ -36,22 +36,20 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
36
36
|
};
|
|
37
37
|
})();
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.assembleContextPlan = exports.Support = exports.defineCandidateSelection = exports.ToolLifecycleRegistry = exports.defineTextSkillLoader = exports.defineRetrieval = exports.
|
|
39
|
+
exports.assembleContextPlan = exports.Support = exports.defineCandidateSelection = exports.ToolLifecycleRegistry = exports.defineTextSkillLoader = exports.defineRetrieval = exports.commandSchema = exports.defineCommand = exports.defineEvidenceProjection = exports.defineEvidenceChecklist = exports.defineRecoveryChain = exports.definePolicySet = exports.ValidationError = exports.BudgetError = exports.getErrorInfo = void 0;
|
|
40
40
|
/**
|
|
41
41
|
* Aggregate public entry of `@jangts/agent-core`: Core runtime contracts, one `Support`
|
|
42
|
-
* namespace
|
|
42
|
+
* namespace, and the optional Kit declaration helpers.
|
|
43
43
|
*
|
|
44
|
-
* Layering. Core owns the runtime contracts Apps call (engine, model runner,
|
|
45
|
-
* context, diagnostics) and the handler contracts Core calls back into
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* and standalone modules, not additional Core guarantees. Shared utilities are re-exported
|
|
50
|
-
* because they are needed alongside these contracts, and they carry no Agent semantics.
|
|
44
|
+
* Layering. Core owns the runtime contracts Apps call (engine, model runner, tools,
|
|
45
|
+
* context, diagnostics) and the handler contracts Core calls back into. Support supplies
|
|
46
|
+
* recommended implementations of those contracts. Kits are optional App-side libraries;
|
|
47
|
+
* they are available from this root convenience surface and from `/kits` / `/kits/*`
|
|
48
|
+
* subpaths. Importing a Kit is a choice, never a requirement.
|
|
51
49
|
*
|
|
52
50
|
* Exports are grouped by responsibility, not by dependency order. Deep subpath entries
|
|
53
51
|
* (`/engine`, `/model`, `/tools`, `/context`, `/journal`, `/diagnostics`, `/kits/...`)
|
|
54
|
-
* resolve to the same implementations
|
|
52
|
+
* resolve to the same implementations.
|
|
55
53
|
*/
|
|
56
54
|
__exportStar(require("./execution/engine.js"), exports);
|
|
57
55
|
var errors_js_1 = require("./errors.js");
|
|
@@ -66,17 +64,23 @@ __exportStar(require("./model/index.js"), exports);
|
|
|
66
64
|
__exportStar(require("./capabilities/index.js"), exports);
|
|
67
65
|
__exportStar(require("./context/fragments.js"), exports);
|
|
68
66
|
__exportStar(require("./context/journal.js"), exports);
|
|
69
|
-
|
|
70
|
-
// root surface publishes separately below.
|
|
71
|
-
var assembly_js_1 = require("./context/assembly.js");
|
|
72
|
-
Object.defineProperty(exports, "assembleFragments", { enumerable: true, get: function () { return assembly_js_1.assembleFragments; } });
|
|
67
|
+
__exportStar(require("./context/assembly.js"), exports);
|
|
73
68
|
__exportStar(require("./support/context/assembly.js"), exports);
|
|
74
69
|
var evidence_js_1 = require("./kits/evidence.js");
|
|
75
70
|
Object.defineProperty(exports, "defineEvidenceChecklist", { enumerable: true, get: function () { return evidence_js_1.defineEvidenceChecklist; } });
|
|
76
71
|
Object.defineProperty(exports, "defineEvidenceProjection", { enumerable: true, get: function () { return evidence_js_1.defineEvidenceProjection; } });
|
|
72
|
+
var command_js_1 = require("./kits/interaction/command.js");
|
|
73
|
+
Object.defineProperty(exports, "defineCommand", { enumerable: true, get: function () { return command_js_1.defineCommand; } });
|
|
74
|
+
Object.defineProperty(exports, "commandSchema", { enumerable: true, get: function () { return command_js_1.commandSchema; } });
|
|
75
|
+
__exportStar(require("./kits/interaction/commands.js"), exports);
|
|
76
|
+
__exportStar(require("./kits/interaction/transfer.js"), exports);
|
|
77
|
+
__exportStar(require("./kits/interaction/handlers.js"), exports);
|
|
77
78
|
__exportStar(require("./kits/presentation/events.js"), exports);
|
|
78
79
|
__exportStar(require("./support/transport/index.js"), exports);
|
|
79
80
|
__exportStar(require("./support/model/chat-completions.js"), exports);
|
|
81
|
+
__exportStar(require("./support/model/compatible-provider.js"), exports);
|
|
82
|
+
__exportStar(require("./support/model/transports.js"), exports);
|
|
83
|
+
__exportStar(require("./support/model/interactions/index.js"), exports);
|
|
80
84
|
__exportStar(require("./utils/index.js"), exports);
|
|
81
85
|
__exportStar(require("./kits/presentation/templates.js"), exports);
|
|
82
86
|
var retrieval_js_1 = require("./kits/retrieval.js");
|
|
@@ -84,11 +88,11 @@ Object.defineProperty(exports, "defineRetrieval", { enumerable: true, get: funct
|
|
|
84
88
|
var text_skills_js_1 = require("./kits/text-skills.js");
|
|
85
89
|
Object.defineProperty(exports, "defineTextSkillLoader", { enumerable: true, get: function () { return text_skills_js_1.defineTextSkillLoader; } });
|
|
86
90
|
__exportStar(require("./diagnostics/index.js"), exports);
|
|
87
|
-
__exportStar(require("./kits/
|
|
88
|
-
__exportStar(require("./kits/
|
|
91
|
+
__exportStar(require("./kits/domains/registry.js"), exports);
|
|
92
|
+
__exportStar(require("./kits/domains/scopes.js"), exports);
|
|
89
93
|
var tools_js_1 = require("./kits/tools.js");
|
|
90
94
|
Object.defineProperty(exports, "ToolLifecycleRegistry", { enumerable: true, get: function () { return tools_js_1.ToolLifecycleRegistry; } });
|
|
91
|
-
__exportStar(require("./kits/
|
|
95
|
+
__exportStar(require("./kits/domains/catalog.js"), exports);
|
|
92
96
|
__exportStar(require("./support/registration.js"), exports);
|
|
93
97
|
var candidates_js_1 = require("./kits/candidates.js");
|
|
94
98
|
Object.defineProperty(exports, "defineCandidateSelection", { enumerable: true, get: function () { return candidates_js_1.defineCandidateSelection; } });
|
|
@@ -55,10 +55,10 @@ function defineAnswerTaskCatalog(definitions, ports) {
|
|
|
55
55
|
!definition.description?.trim() ||
|
|
56
56
|
!readers.has(definition.readerId) ||
|
|
57
57
|
!outputs.has(definition.outputId) ||
|
|
58
|
-
!Array.isArray(definition.
|
|
59
|
-
!definition.
|
|
60
|
-
definition.
|
|
61
|
-
new Set(definition.
|
|
58
|
+
!Array.isArray(definition.goalIds) ||
|
|
59
|
+
!definition.goalIds.length ||
|
|
60
|
+
definition.goalIds.some((id) => typeof id !== 'string' || !id.trim()) ||
|
|
61
|
+
new Set(definition.goalIds).size !== definition.goalIds.length ||
|
|
62
62
|
!Array.isArray(definition.checkIds) ||
|
|
63
63
|
new Set(definition.checkIds).size !== definition.checkIds.length ||
|
|
64
64
|
definition.checkIds.some((id) => !checkIds.includes(id)))
|
|
@@ -72,7 +72,7 @@ function defineAnswerTaskCatalog(definitions, ports) {
|
|
|
72
72
|
readerId: definition.readerId,
|
|
73
73
|
outputId: definition.outputId,
|
|
74
74
|
scopeId: definition.scopeId,
|
|
75
|
-
|
|
75
|
+
goalIds: Object.freeze([...definition.goalIds]),
|
|
76
76
|
checkIds: Object.freeze([...definition.checkIds]),
|
|
77
77
|
inputSchema: (0, schema_adapter_js_1.snapshotSchemaAdapter)(definition.inputSchema),
|
|
78
78
|
metadata,
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defineAgentCatalog = defineAgentCatalog;
|
|
4
|
+
/**
|
|
5
|
+
* Domain Tools Kit: project registered goals, scopes and tools into one task-facing catalog.
|
|
6
|
+
*
|
|
7
|
+
* Place in the package: part of the domain Tool Kit. It reads the actual registries supplied by
|
|
8
|
+
* the App instead of maintaining a parallel capability list, so an intent is only advertised
|
|
9
|
+
* when its tools, scopes and availability agree.
|
|
10
|
+
*
|
|
11
|
+
* Exports: `defineAgentCatalog`, and the catalog intent/scope/port types.
|
|
12
|
+
*/
|
|
13
|
+
const synchronous_js_1 = require("../../utils/synchronous.js");
|
|
14
|
+
const tool_conditions_js_1 = require("../../capabilities/tool-conditions.js");
|
|
15
|
+
/**
|
|
16
|
+
* Compile a catalog projection over the App's live registries.
|
|
17
|
+
*
|
|
18
|
+
* The actual registries determine availability and relationships. No parallel capability list
|
|
19
|
+
* exists: `goalIds` filters by tool support, `modelCatalog` narrows to the currently accepted
|
|
20
|
+
* task when `restrictToTask` is enabled, and scope tool ids are filtered to tools that exist.
|
|
21
|
+
*
|
|
22
|
+
* @param ports - Sources for Tool ids, goals, scopes, the current task, the tool registry
|
|
23
|
+
* and the `restrictToTask` switch.
|
|
24
|
+
* @returns A frozen projection with `goalIds`, `goalDelegates`, `goalCatalog`,
|
|
25
|
+
* `scopeCatalog` and `modelCatalog`.
|
|
26
|
+
* @throws TypeError When a supplied predicate does not return a boolean synchronously.
|
|
27
|
+
*/
|
|
28
|
+
function defineAgentCatalog(ports) {
|
|
29
|
+
const ids = ports.goalIds.bind(ports), goals = ports.goals.bind(ports), scopes = ports.scopes.bind(ports), task = ports.currentTask.bind(ports);
|
|
30
|
+
const tools = {
|
|
31
|
+
values: ports.tools.values.bind(ports.tools),
|
|
32
|
+
has: ports.tools.has.bind(ports.tools),
|
|
33
|
+
supports: ports.tools.supportsGoal.bind(ports.tools),
|
|
34
|
+
describe: ports.tools.describe.bind(ports.tools),
|
|
35
|
+
};
|
|
36
|
+
const restrict = ports.restrictToTask !== false;
|
|
37
|
+
const boolean = (value) => (0, synchronous_js_1.booleanResult)(value, 'Catalog predicates must be synchronous', 'Catalog predicates must return boolean');
|
|
38
|
+
/** Whether one goal is active and its demand metadata currently participates. */
|
|
39
|
+
const goalAvailable = (goal, app) => {
|
|
40
|
+
const tool = goal;
|
|
41
|
+
if (!(0, tool_conditions_js_1.toolActive)(tool.active, app))
|
|
42
|
+
return false;
|
|
43
|
+
const metadata = tool.asIntent;
|
|
44
|
+
if (metadata === undefined || metadata === true || typeof metadata === 'string')
|
|
45
|
+
return true;
|
|
46
|
+
if (typeof metadata === 'function')
|
|
47
|
+
return (0, tool_conditions_js_1.toolActive)(metadata, app);
|
|
48
|
+
return (0, tool_conditions_js_1.toolActive)(metadata.when, app);
|
|
49
|
+
};
|
|
50
|
+
const goalIds = (app) => ids(app).filter((id) => boolean(tools.supports(id, app)));
|
|
51
|
+
const goalDelegates = (app) => new Map(goals().map((goal) => {
|
|
52
|
+
const metadata = goal.asIntent;
|
|
53
|
+
const explicit = typeof metadata === 'object' ? metadata.delegates : undefined;
|
|
54
|
+
return [
|
|
55
|
+
goal.id,
|
|
56
|
+
explicit
|
|
57
|
+
? [...explicit]
|
|
58
|
+
: [
|
|
59
|
+
...new Set([
|
|
60
|
+
...goal.delegates,
|
|
61
|
+
...[...tools.values()]
|
|
62
|
+
.filter((tool) => tool.lifecycle?.id &&
|
|
63
|
+
(app === undefined || (0, tool_conditions_js_1.toolActive)(tool.active, app)) &&
|
|
64
|
+
(tool.goalIds === 'all' || tool.goalIds.includes(goal.id)))
|
|
65
|
+
.map((tool) => tool.lifecycle.id),
|
|
66
|
+
]),
|
|
67
|
+
],
|
|
68
|
+
];
|
|
69
|
+
}));
|
|
70
|
+
const goalCatalog = (app) => {
|
|
71
|
+
const selected = goalIds(app), described = tools.describe('model', app), delegates = goalDelegates(app);
|
|
72
|
+
return goals(selected)
|
|
73
|
+
.filter((goal) => goalAvailable(goal, app))
|
|
74
|
+
.map((goal) => {
|
|
75
|
+
const { inputSchema: _schema, resolve: _resolve, active: _active, asIntent: _asIntent, ...metadata } = goal;
|
|
76
|
+
const demandDescription = typeof _asIntent === 'string'
|
|
77
|
+
? _asIntent
|
|
78
|
+
: typeof _asIntent === 'object' && _asIntent !== null
|
|
79
|
+
? _asIntent.description
|
|
80
|
+
: undefined;
|
|
81
|
+
return {
|
|
82
|
+
...metadata,
|
|
83
|
+
...(demandDescription ? { description: demandDescription } : {}),
|
|
84
|
+
delegates: delegates.get(goal.id) ?? [...goal.delegates],
|
|
85
|
+
scopeIds: scopes([goal.id]).map((scope) => scope.id),
|
|
86
|
+
toolIds: described
|
|
87
|
+
.filter((tool) => tool.goalIds.includes(goal.id))
|
|
88
|
+
.map((tool) => tool.id),
|
|
89
|
+
};
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
const scopeCatalog = (app) => scopes(goalCatalog(app).map((goal) => goal.id)).map((scope) => ({
|
|
93
|
+
...scope,
|
|
94
|
+
toolIds: scope.toolIds.filter(tools.has),
|
|
95
|
+
}));
|
|
96
|
+
return Object.freeze({
|
|
97
|
+
goalIds,
|
|
98
|
+
goalDelegates,
|
|
99
|
+
goalCatalog,
|
|
100
|
+
scopeCatalog,
|
|
101
|
+
modelCatalog(app) {
|
|
102
|
+
const accepted = restrict ? task(app) : undefined, selected = goalIds(app).filter((id) => !accepted || id === accepted.goalId), available = goalCatalog(app).filter((intent) => selected.includes(intent.id));
|
|
103
|
+
return {
|
|
104
|
+
availableGoalIds: available.map((intent) => intent.id),
|
|
105
|
+
availableGoals: available.map((intent) => accepted ? { ...intent, scopeIds: accepted.scopeId ? [accepted.scopeId] : [] } : intent),
|
|
106
|
+
availableScopes: scopeCatalog(app).filter((scope) => !accepted || scope.id === accepted.scopeId),
|
|
107
|
+
availableTools: tools
|
|
108
|
+
.describe('model', app)
|
|
109
|
+
.filter((tool) => !accepted || tool.goalIds.includes(accepted.goalId)),
|
|
110
|
+
};
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
/** Optional domain Tool constraints, scope registries and task-facing projections. */
|
|
18
|
+
__exportStar(require("./registry.js"), exports);
|
|
19
|
+
__exportStar(require("./scopes.js"), exports);
|
|
20
|
+
__exportStar(require("./catalog.js"), exports);
|
|
@@ -5,8 +5,9 @@ exports.createIntentRegistry = createIntentRegistry;
|
|
|
5
5
|
const synchronous_js_1 = require("../../utils/synchronous.js");
|
|
6
6
|
const rules_js_1 = require("../../utils/rules.js");
|
|
7
7
|
const registration_js_1 = require("../../utils/registration.js");
|
|
8
|
+
const model_js_1 = require("../../capabilities/model.js");
|
|
8
9
|
/**
|
|
9
|
-
*
|
|
10
|
+
* Goal semantics and allowed values are configuration; the registry owns their common lifecycle.
|
|
10
11
|
*
|
|
11
12
|
* Registration order is preserved by `ids`, `definitions`, `values` and `entries`; once
|
|
12
13
|
* `seal()` is called the set is final and further registration is rejected.
|
|
@@ -16,6 +17,7 @@ class IntentRegistry {
|
|
|
16
17
|
static create = createIntentRegistry;
|
|
17
18
|
byId = new Map();
|
|
18
19
|
sealed = false;
|
|
20
|
+
modelView;
|
|
19
21
|
policy;
|
|
20
22
|
/**
|
|
21
23
|
* @param policy - Optional id pattern, vocabulary lists, error wording and assertion hook.
|
|
@@ -29,7 +31,7 @@ class IntentRegistry {
|
|
|
29
31
|
'targetModes',
|
|
30
32
|
'contextTiers',
|
|
31
33
|
'actions',
|
|
32
|
-
'
|
|
34
|
+
'delegates',
|
|
33
35
|
'handoffValues',
|
|
34
36
|
'tags',
|
|
35
37
|
];
|
|
@@ -51,16 +53,16 @@ class IntentRegistry {
|
|
|
51
53
|
});
|
|
52
54
|
}
|
|
53
55
|
/**
|
|
54
|
-
* Validate, freeze and add one
|
|
56
|
+
* Validate, freeze and add one domain Tool.
|
|
55
57
|
*
|
|
56
58
|
* Checks run in a fixed order — sealed, identity, context contract, auxiliary actions,
|
|
57
|
-
* handoff, plan,
|
|
59
|
+
* handoff, plan, delegates — so the reported violation is stable when several rules fail.
|
|
58
60
|
*
|
|
59
|
-
* @param input -
|
|
61
|
+
* @param input - Goal declaration; the App's own assertion receives this original object,
|
|
60
62
|
* not the compiled copy, so helpers and prototype methods keep working.
|
|
61
63
|
* @returns This registry, for chaining.
|
|
62
64
|
* @throws A configured error for a sealed registry, invalid identity or vocabulary values,
|
|
63
|
-
* empty/duplicate
|
|
65
|
+
* empty/duplicate delegates, or a duplicate Tool id.
|
|
64
66
|
*/
|
|
65
67
|
register(input) {
|
|
66
68
|
const id = input.id;
|
|
@@ -68,7 +70,7 @@ class IntentRegistry {
|
|
|
68
70
|
...(0, registration_js_1.registrationData)(input, [
|
|
69
71
|
'id',
|
|
70
72
|
'description',
|
|
71
|
-
'
|
|
73
|
+
'delegates',
|
|
72
74
|
'scopePolicy',
|
|
73
75
|
'targetPolicy',
|
|
74
76
|
'contextTier',
|
|
@@ -78,7 +80,11 @@ class IntentRegistry {
|
|
|
78
80
|
]),
|
|
79
81
|
id,
|
|
80
82
|
description: input.description,
|
|
81
|
-
|
|
83
|
+
delegates: (typeof input.asIntent === 'object' && input.asIntent !== null
|
|
84
|
+
? input.asIntent.delegates
|
|
85
|
+
: undefined) ??
|
|
86
|
+
input.delegates ??
|
|
87
|
+
[],
|
|
82
88
|
scopePolicy: input.scopePolicy,
|
|
83
89
|
targetPolicy: input.targetPolicy,
|
|
84
90
|
contextTier: input.contextTier,
|
|
@@ -87,7 +93,7 @@ class IntentRegistry {
|
|
|
87
93
|
preparedHandoff: input.preparedHandoff,
|
|
88
94
|
};
|
|
89
95
|
const policy = this.policy;
|
|
90
|
-
const invalid = policy.errors?.invalid ?? 'Invalid intent definition';
|
|
96
|
+
const invalid = policy.errors?.invalid ?? 'Invalid intent Tool definition';
|
|
91
97
|
const tags = policy.tags ?? [];
|
|
92
98
|
const validName = (name) => {
|
|
93
99
|
if (typeof name !== 'string' || !name.trim())
|
|
@@ -145,75 +151,112 @@ class IntentRegistry {
|
|
|
145
151
|
},
|
|
146
152
|
{
|
|
147
153
|
occur: [
|
|
148
|
-
() =>
|
|
149
|
-
|
|
150
|
-
|
|
154
|
+
() => (input.delegates !== undefined ||
|
|
155
|
+
(typeof input.asIntent === 'object' &&
|
|
156
|
+
input.asIntent !== null &&
|
|
157
|
+
input.asIntent.delegates !== undefined)) &&
|
|
158
|
+
!definition.delegates.length,
|
|
159
|
+
() => definition.delegates.some((delegate) => policy.delegates !== undefined && !policy.delegates.includes(delegate)),
|
|
160
|
+
() => new Set(definition.delegates).size !== definition.delegates.length,
|
|
151
161
|
],
|
|
152
162
|
error: invalid,
|
|
153
|
-
tags: ['
|
|
163
|
+
tags: ['delegates'],
|
|
154
164
|
},
|
|
155
165
|
], tags);
|
|
156
166
|
// App assertions may use implementation helpers; never pass a compiled view as the source
|
|
157
167
|
// instance.
|
|
158
168
|
(0, synchronous_js_1.assertion)(policy.assertDefinition?.(input), 'Registry definition assertions must return void synchronously');
|
|
159
|
-
(0, rules_js_1.breakWhile)(this.byId.has(definition.id), () => policy.errors?.duplicate?.(definition.id) ??
|
|
160
|
-
new Error(`Duplicate intent: ${definition.id}`), [...tags, 'duplicate']);
|
|
169
|
+
(0, rules_js_1.breakWhile)(this.byId.has(definition.id), () => policy.errors?.duplicate?.(definition.id) ?? new Error(`Duplicate tool: ${definition.id}`), [...tags, 'duplicate']);
|
|
161
170
|
this.byId.set(definition.id, Object.freeze({
|
|
162
171
|
...definition,
|
|
163
|
-
|
|
172
|
+
...new model_js_1.ModelToolRegistry([
|
|
173
|
+
{
|
|
174
|
+
id: input.id,
|
|
175
|
+
description: input.description,
|
|
176
|
+
active: typeof input.active === 'function' ? input.active.bind(input) : input.active,
|
|
177
|
+
asIntent: typeof input.asIntent === 'function' ? input.asIntent.bind(input) : input.asIntent,
|
|
178
|
+
inputSchema: input.inputSchema ?? {
|
|
179
|
+
jsonSchema: { type: 'object' },
|
|
180
|
+
parse(value) {
|
|
181
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
182
|
+
throw new TypeError('Tool input must be an object');
|
|
183
|
+
return value;
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
resolve: input.resolve?.bind(input) ?? ((value) => ({ toolId: id, input: value })),
|
|
187
|
+
},
|
|
188
|
+
]).require(input.id),
|
|
189
|
+
delegates: Object.freeze([...definition.delegates]),
|
|
164
190
|
...(definition.auxiliaryActions
|
|
165
191
|
? { auxiliaryActions: Object.freeze([...definition.auxiliaryActions]) }
|
|
166
192
|
: {}),
|
|
167
193
|
}));
|
|
194
|
+
this.modelView = undefined;
|
|
168
195
|
return this;
|
|
169
196
|
}
|
|
170
|
-
/** Register every
|
|
197
|
+
/** Register every domain Tool in iteration order. */
|
|
171
198
|
registerAll(definitions) {
|
|
172
199
|
for (const definition of definitions)
|
|
173
200
|
this.register(definition);
|
|
174
201
|
return this;
|
|
175
202
|
}
|
|
176
|
-
/** Registered
|
|
203
|
+
/** Registered domain Tool for `id`, or `undefined` when it is absent. */
|
|
177
204
|
get(goal) {
|
|
178
205
|
return this.byId.get(goal);
|
|
179
206
|
}
|
|
180
|
-
/** Whether
|
|
207
|
+
/** Whether a Tool id is registered. */
|
|
181
208
|
has(goal) {
|
|
182
209
|
return this.byId.has(goal);
|
|
183
210
|
}
|
|
184
|
-
/** Registered
|
|
211
|
+
/** Registered Tool ids in registration order. */
|
|
185
212
|
ids() {
|
|
186
213
|
return Object.freeze([...this.byId.keys()]);
|
|
187
214
|
}
|
|
188
|
-
/** Registered
|
|
215
|
+
/** Registered goals in registration order. */
|
|
189
216
|
get definitions() {
|
|
190
217
|
return Object.freeze([...this.byId.values()]);
|
|
191
218
|
}
|
|
192
|
-
/** Iterate the registered
|
|
219
|
+
/** Iterate the registered goals. */
|
|
193
220
|
values() {
|
|
194
221
|
return this.byId.values();
|
|
195
222
|
}
|
|
196
|
-
/**
|
|
223
|
+
/** Demand discovery uses tool metadata; domain fields remain attached to these same IDs. */
|
|
224
|
+
withIntent(context) {
|
|
225
|
+
return this.models().withIntent(context);
|
|
226
|
+
}
|
|
227
|
+
/** Resolve a grouped transport's selected Tool through that Tool's own parser and resolver. */
|
|
228
|
+
resolve(selection, context) {
|
|
229
|
+
return this.models().resolve(selection, context);
|
|
230
|
+
}
|
|
231
|
+
/** Explicit node selection uses the same immutable model projection. */
|
|
232
|
+
select(ids, ...context) {
|
|
233
|
+
return context.length ? this.models().select(ids, context[0]) : this.models().select(ids);
|
|
234
|
+
}
|
|
235
|
+
/** Cache only immutable declarations; request activation is evaluated by each projection. */
|
|
236
|
+
models() {
|
|
237
|
+
return (this.modelView ??= new model_js_1.ModelToolRegistry(this.byId.values()).seal());
|
|
238
|
+
}
|
|
239
|
+
/** Iterate `[id, tool]` pairs. */
|
|
197
240
|
entries() {
|
|
198
241
|
return this.byId.entries();
|
|
199
242
|
}
|
|
200
243
|
/**
|
|
201
|
-
* Registered
|
|
244
|
+
* Registered domain Tool for `id`.
|
|
202
245
|
*
|
|
203
246
|
* @throws TypeError When the id is not registered.
|
|
204
247
|
*/
|
|
205
248
|
require(id) {
|
|
206
249
|
const value = this.byId.get(id);
|
|
207
250
|
if (!value)
|
|
208
|
-
throw new TypeError(`Unknown
|
|
251
|
+
throw new TypeError(`Unknown tool: ${id}`);
|
|
209
252
|
return value;
|
|
210
253
|
}
|
|
211
|
-
/** Whether the
|
|
212
|
-
allows(goal,
|
|
213
|
-
return this.byId.get(goal)?.
|
|
254
|
+
/** Whether the Tool declares this delegate; unknown goals allow nothing. */
|
|
255
|
+
allows(goal, delegate) {
|
|
256
|
+
return this.byId.get(goal)?.delegates.includes(delegate) ?? false;
|
|
214
257
|
}
|
|
215
258
|
/**
|
|
216
|
-
* Copy the selected
|
|
259
|
+
* Copy the selected goals out of the registry.
|
|
217
260
|
*
|
|
218
261
|
* @param goals - Ids to include; the default is every registered id, in registry order.
|
|
219
262
|
* @returns Descriptions whose arrays are copied so callers cannot mutate registry state.
|
|
@@ -222,7 +265,10 @@ class IntentRegistry {
|
|
|
222
265
|
const selected = new Set(goals);
|
|
223
266
|
return [...this.byId.values()]
|
|
224
267
|
.filter((item) => selected.has(item.id))
|
|
225
|
-
.map((item) => ({
|
|
268
|
+
.map((item) => ({
|
|
269
|
+
...item,
|
|
270
|
+
delegates: [...item.delegates],
|
|
271
|
+
}));
|
|
226
272
|
}
|
|
227
273
|
/** Finalize the registry; no registration is accepted afterwards. */
|
|
228
274
|
seal() {
|
|
@@ -234,7 +280,7 @@ exports.IntentRegistry = IntentRegistry;
|
|
|
234
280
|
/**
|
|
235
281
|
* Create and seal a complete catalog; use the constructor for incremental installation.
|
|
236
282
|
*
|
|
237
|
-
* @param definitions -
|
|
283
|
+
* @param definitions - Goal declarations registered in iteration order.
|
|
238
284
|
* @param policy - Optional registry policy forwarded to the constructor.
|
|
239
285
|
* @returns A sealed registry.
|
|
240
286
|
* @throws A configured error for the first invalid or duplicate declaration.
|
|
@@ -35,7 +35,7 @@ class ScopeRegistry {
|
|
|
35
35
|
...(0, registration_js_1.registrationData)(policy, [
|
|
36
36
|
'idPattern',
|
|
37
37
|
'assertDefinition',
|
|
38
|
-
'
|
|
38
|
+
'acceptsTool',
|
|
39
39
|
'errors',
|
|
40
40
|
...listFields,
|
|
41
41
|
]),
|
|
@@ -47,7 +47,7 @@ class ScopeRegistry {
|
|
|
47
47
|
invalid: typeof invalid === 'function' ? invalid.bind(errorPorts) : invalid,
|
|
48
48
|
}),
|
|
49
49
|
assertDefinition: policy.assertDefinition?.bind(policy),
|
|
50
|
-
|
|
50
|
+
acceptsTool: policy.acceptsTool?.bind(policy),
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
@@ -56,11 +56,11 @@ class ScopeRegistry {
|
|
|
56
56
|
* Every name is checked for conflicts before any of them is stored, so a rejected scope
|
|
57
57
|
* leaves no partial alias entry behind.
|
|
58
58
|
*
|
|
59
|
-
* @param input - Scope declaration; the raw object is retained for `
|
|
59
|
+
* @param input - Scope declaration; the raw object is retained for `acceptsTool` overrides
|
|
60
60
|
* while the compiled copy serves lookups.
|
|
61
61
|
* @returns This registry, for chaining.
|
|
62
62
|
* @throws A configured error for a sealed registry, an invalid name/description/category,
|
|
63
|
-
* a missing required binding, duplicate
|
|
63
|
+
* a missing required binding, duplicate Tool ids or an already-claimed name.
|
|
64
64
|
*/
|
|
65
65
|
register(input) {
|
|
66
66
|
const definition = {
|
|
@@ -68,7 +68,7 @@ class ScopeRegistry {
|
|
|
68
68
|
'id',
|
|
69
69
|
'description',
|
|
70
70
|
'category',
|
|
71
|
-
'
|
|
71
|
+
'goalIds',
|
|
72
72
|
'queryScopeIds',
|
|
73
73
|
'knowledgeTopicIds',
|
|
74
74
|
'toolIds',
|
|
@@ -79,7 +79,7 @@ class ScopeRegistry {
|
|
|
79
79
|
id: input.id,
|
|
80
80
|
description: input.description,
|
|
81
81
|
category: input.category,
|
|
82
|
-
|
|
82
|
+
goalIds: input.goalIds ?? [],
|
|
83
83
|
queryScopeIds: input.queryScopeIds ?? [],
|
|
84
84
|
knowledgeTopicIds: input.knowledgeTopicIds ?? [],
|
|
85
85
|
toolIds: input.toolIds ?? [],
|
|
@@ -114,9 +114,9 @@ class ScopeRegistry {
|
|
|
114
114
|
tags: ['identity'],
|
|
115
115
|
},
|
|
116
116
|
{
|
|
117
|
-
occur: () => policy.
|
|
117
|
+
occur: () => policy.requireGoals === true && !definition.goalIds.length,
|
|
118
118
|
error: invalid,
|
|
119
|
-
tags: ['
|
|
119
|
+
tags: ['goals', 'required'],
|
|
120
120
|
},
|
|
121
121
|
{
|
|
122
122
|
occur: [
|
|
@@ -130,18 +130,18 @@ class ScopeRegistry {
|
|
|
130
130
|
},
|
|
131
131
|
{
|
|
132
132
|
occur: [
|
|
133
|
-
() => definition.
|
|
134
|
-
() => new Set(definition.
|
|
133
|
+
() => definition.goalIds.some((intent) => typeof intent !== 'string'),
|
|
134
|
+
() => new Set(definition.goalIds).size !== definition.goalIds.length,
|
|
135
135
|
],
|
|
136
136
|
error: invalid,
|
|
137
|
-
tags: ['
|
|
137
|
+
tags: ['goals', 'values'],
|
|
138
138
|
},
|
|
139
139
|
], tags);
|
|
140
140
|
(0, synchronous_js_1.assertion)(policy.assertDefinition?.(input), 'Registry definition assertions must return void synchronously');
|
|
141
141
|
(0, rules_js_1.breakWhile)(names.some((name) => this.byId.has(name) || this.aliases.has(name)), invalid, [...tags, 'duplicate']);
|
|
142
142
|
const frozen = Object.freeze({
|
|
143
143
|
...definition,
|
|
144
|
-
|
|
144
|
+
goalIds: Object.freeze([...definition.goalIds]),
|
|
145
145
|
toolIds: Object.freeze([...definition.toolIds]),
|
|
146
146
|
queryScopeIds: Object.freeze([...definition.queryScopeIds]),
|
|
147
147
|
knowledgeTopicIds: Object.freeze([...definition.knowledgeTopicIds]),
|
|
@@ -207,16 +207,16 @@ class ScopeRegistry {
|
|
|
207
207
|
/**
|
|
208
208
|
* Whether a scope accepts an intent.
|
|
209
209
|
*
|
|
210
|
-
* The App may override the declared `
|
|
210
|
+
* The App may override the declared `goalIds` through `acceptsTool`; without an
|
|
211
211
|
* override the membership check applies.
|
|
212
212
|
*/
|
|
213
|
-
|
|
213
|
+
acceptsTool(scope, goal) {
|
|
214
214
|
const definition = this.get(scope);
|
|
215
215
|
if (!definition)
|
|
216
216
|
return false;
|
|
217
|
-
const ids = definition.
|
|
218
|
-
return this.policy.
|
|
219
|
-
? (0, synchronous_js_1.booleanResult)(this.policy.
|
|
217
|
+
const ids = definition.goalIds;
|
|
218
|
+
return this.policy.acceptsTool
|
|
219
|
+
? (0, synchronous_js_1.booleanResult)(this.policy.acceptsTool(this.sources.get(this.normalize(scope)), goal), 'Scope intent predicates must return boolean synchronously')
|
|
220
220
|
: ids.includes(goal);
|
|
221
221
|
}
|
|
222
222
|
/** Whether the scope declares this query scope; a null scope accepts nothing. */
|
|
@@ -245,18 +245,18 @@ class ScopeRegistry {
|
|
|
245
245
|
return this.get(scope)?.contextTier;
|
|
246
246
|
}
|
|
247
247
|
/**
|
|
248
|
-
* Copy the scopes that accept at least one of the given
|
|
248
|
+
* Copy the scopes that accept at least one of the given goals.
|
|
249
249
|
*
|
|
250
|
-
* @param goals -
|
|
250
|
+
* @param goals - Goal ids to filter by; omit to include every registered scope.
|
|
251
251
|
* @returns Descriptions whose arrays are copied so callers cannot mutate registry state.
|
|
252
252
|
*/
|
|
253
253
|
describe(goals) {
|
|
254
254
|
const selected = goals ? new Set(goals) : undefined;
|
|
255
255
|
return [...this.byId.values()]
|
|
256
|
-
.filter((item) => !selected || item.
|
|
256
|
+
.filter((item) => !selected || item.goalIds.some((goal) => selected.has(goal)))
|
|
257
257
|
.map((item) => ({
|
|
258
258
|
...item,
|
|
259
|
-
|
|
259
|
+
goalIds: [...item.goalIds],
|
|
260
260
|
queryScopeIds: [...item.queryScopeIds],
|
|
261
261
|
knowledgeTopicIds: [...item.knowledgeTopicIds],
|
|
262
262
|
toolIds: [...item.toolIds],
|