@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
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Aggregate public entry of `@jangts/agent-core`: Core runtime contracts, one `Support`
|
|
3
|
-
* namespace
|
|
3
|
+
* namespace, and the optional Kit declaration helpers.
|
|
4
4
|
*
|
|
5
|
-
* Layering. Core owns the runtime contracts Apps call (engine, model runner,
|
|
6
|
-
* context, diagnostics) and the handler contracts Core calls back into
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* and standalone modules, not additional Core guarantees. Shared utilities are re-exported
|
|
11
|
-
* because they are needed alongside these contracts, and they carry no Agent semantics.
|
|
5
|
+
* Layering. Core owns the runtime contracts Apps call (engine, model runner, tools,
|
|
6
|
+
* context, diagnostics) and the handler contracts Core calls back into. Support supplies
|
|
7
|
+
* recommended implementations of those contracts. Kits are optional App-side libraries;
|
|
8
|
+
* they are available from this root convenience surface and from `/kits` / `/kits/*`
|
|
9
|
+
* subpaths. Importing a Kit is a choice, never a requirement.
|
|
12
10
|
*
|
|
13
11
|
* Exports are grouped by responsibility, not by dependency order. Deep subpath entries
|
|
14
12
|
* (`/engine`, `/model`, `/tools`, `/context`, `/journal`, `/diagnostics`, `/kits/...`)
|
|
15
|
-
* resolve to the same implementations
|
|
13
|
+
* resolve to the same implementations.
|
|
16
14
|
*/
|
|
17
15
|
export * from './execution/engine.js';
|
|
18
16
|
export { getErrorInfo } from './errors.js';
|
|
@@ -23,13 +21,21 @@ export * from './model/index.js';
|
|
|
23
21
|
export * from './capabilities/index.js';
|
|
24
22
|
export * from './context/fragments.js';
|
|
25
23
|
export * from './context/journal.js';
|
|
26
|
-
export
|
|
24
|
+
export * from './context/assembly.js';
|
|
27
25
|
export * from './support/context/assembly.js';
|
|
28
26
|
export { defineEvidenceChecklist, defineEvidenceProjection } from './kits/evidence.js';
|
|
29
27
|
export type { EvidenceRequirement, EvidenceProvider, EvidenceProjectionDefinition, EvidenceProjectionProvider, } from './structs/kits/evidence.js';
|
|
28
|
+
export { defineCommand, commandSchema } from './kits/interaction/command.js';
|
|
29
|
+
export type { Command, CommandDefinition, ProtocolCheck, ProtocolField, ProtocolReason, ProtocolPredicate, ProtocolShape, RegisteredProtocol, } from './structs/kits/interaction.js';
|
|
30
|
+
export * from './kits/interaction/commands.js';
|
|
31
|
+
export * from './kits/interaction/transfer.js';
|
|
32
|
+
export * from './kits/interaction/handlers.js';
|
|
30
33
|
export * from './kits/presentation/events.js';
|
|
31
34
|
export * from './support/transport/index.js';
|
|
32
35
|
export * from './support/model/chat-completions.js';
|
|
36
|
+
export * from './support/model/compatible-provider.js';
|
|
37
|
+
export * from './support/model/transports.js';
|
|
38
|
+
export * from './support/model/interactions/index.js';
|
|
33
39
|
export * from './utils/index.js';
|
|
34
40
|
export * from './kits/presentation/templates.js';
|
|
35
41
|
export { defineRetrieval } from './kits/retrieval.js';
|
|
@@ -37,11 +43,11 @@ export type * from './structs/kits/retrieval.js';
|
|
|
37
43
|
export { defineTextSkillLoader } from './kits/text-skills.js';
|
|
38
44
|
export type * from './structs/kits/text-skills.js';
|
|
39
45
|
export * from './diagnostics/index.js';
|
|
40
|
-
export * from './kits/
|
|
41
|
-
export * from './kits/
|
|
46
|
+
export * from './kits/domains/registry.js';
|
|
47
|
+
export * from './kits/domains/scopes.js';
|
|
42
48
|
export { ToolLifecycleRegistry } from './kits/tools.js';
|
|
43
49
|
export type * from './structs/kits/tools.js';
|
|
44
|
-
export * from './kits/
|
|
50
|
+
export * from './kits/domains/catalog.js';
|
|
45
51
|
export * from './support/registration.js';
|
|
46
52
|
export { defineCandidateSelection } from './kits/candidates.js';
|
|
47
53
|
export type * from './structs/kits/candidates.js';
|
package/dist/esm/index.js
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Aggregate public entry of `@jangts/agent-core`: Core runtime contracts, one `Support`
|
|
3
|
-
* namespace
|
|
3
|
+
* namespace, and the optional Kit declaration helpers.
|
|
4
4
|
*
|
|
5
|
-
* Layering. Core owns the runtime contracts Apps call (engine, model runner,
|
|
6
|
-
* context, diagnostics) and the handler contracts Core calls back into
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* and standalone modules, not additional Core guarantees. Shared utilities are re-exported
|
|
11
|
-
* because they are needed alongside these contracts, and they carry no Agent semantics.
|
|
5
|
+
* Layering. Core owns the runtime contracts Apps call (engine, model runner, tools,
|
|
6
|
+
* context, diagnostics) and the handler contracts Core calls back into. Support supplies
|
|
7
|
+
* recommended implementations of those contracts. Kits are optional App-side libraries;
|
|
8
|
+
* they are available from this root convenience surface and from `/kits` / `/kits/*`
|
|
9
|
+
* subpaths. Importing a Kit is a choice, never a requirement.
|
|
12
10
|
*
|
|
13
11
|
* Exports are grouped by responsibility, not by dependency order. Deep subpath entries
|
|
14
12
|
* (`/engine`, `/model`, `/tools`, `/context`, `/journal`, `/diagnostics`, `/kits/...`)
|
|
15
|
-
* resolve to the same implementations
|
|
13
|
+
* resolve to the same implementations.
|
|
16
14
|
*/
|
|
17
15
|
export * from './execution/engine.js';
|
|
18
16
|
export { getErrorInfo } from './errors.js';
|
|
@@ -22,23 +20,28 @@ export * from './model/index.js';
|
|
|
22
20
|
export * from './capabilities/index.js';
|
|
23
21
|
export * from './context/fragments.js';
|
|
24
22
|
export * from './context/journal.js';
|
|
25
|
-
|
|
26
|
-
// root surface publishes separately below.
|
|
27
|
-
export { assembleFragments } from './context/assembly.js';
|
|
23
|
+
export * from './context/assembly.js';
|
|
28
24
|
export * from './support/context/assembly.js';
|
|
29
25
|
export { defineEvidenceChecklist, defineEvidenceProjection } from './kits/evidence.js';
|
|
26
|
+
export { defineCommand, commandSchema } from './kits/interaction/command.js';
|
|
27
|
+
export * from './kits/interaction/commands.js';
|
|
28
|
+
export * from './kits/interaction/transfer.js';
|
|
29
|
+
export * from './kits/interaction/handlers.js';
|
|
30
30
|
export * from './kits/presentation/events.js';
|
|
31
31
|
export * from './support/transport/index.js';
|
|
32
32
|
export * from './support/model/chat-completions.js';
|
|
33
|
+
export * from './support/model/compatible-provider.js';
|
|
34
|
+
export * from './support/model/transports.js';
|
|
35
|
+
export * from './support/model/interactions/index.js';
|
|
33
36
|
export * from './utils/index.js';
|
|
34
37
|
export * from './kits/presentation/templates.js';
|
|
35
38
|
export { defineRetrieval } from './kits/retrieval.js';
|
|
36
39
|
export { defineTextSkillLoader } from './kits/text-skills.js';
|
|
37
40
|
export * from './diagnostics/index.js';
|
|
38
|
-
export * from './kits/
|
|
39
|
-
export * from './kits/
|
|
41
|
+
export * from './kits/domains/registry.js';
|
|
42
|
+
export * from './kits/domains/scopes.js';
|
|
40
43
|
export { ToolLifecycleRegistry } from './kits/tools.js';
|
|
41
|
-
export * from './kits/
|
|
44
|
+
export * from './kits/domains/catalog.js';
|
|
42
45
|
export * from './support/registration.js';
|
|
43
46
|
export { defineCandidateSelection } from './kits/candidates.js';
|
|
44
47
|
/** App-facing helpers and their types are consumed through the root Support namespace. */
|
|
@@ -36,7 +36,7 @@ export declare function defineAnswerTaskCatalog<Input, Evidence, App, Data = unk
|
|
|
36
36
|
readerId: string;
|
|
37
37
|
outputId: string;
|
|
38
38
|
scopeId: string | undefined;
|
|
39
|
-
|
|
39
|
+
goalIds: readonly any[];
|
|
40
40
|
checkIds: readonly any[];
|
|
41
41
|
metadata: Data;
|
|
42
42
|
}[];
|
|
@@ -64,7 +64,7 @@ export declare function defineAnswerTaskCatalog<Input, Evidence, App, Data = unk
|
|
|
64
64
|
readerId: string;
|
|
65
65
|
outputId: string;
|
|
66
66
|
scopeId: string | undefined;
|
|
67
|
-
|
|
67
|
+
goalIds: readonly any[];
|
|
68
68
|
checkIds: readonly any[];
|
|
69
69
|
inputSchema: import("../../index.js").SchemaAdapter<Input>;
|
|
70
70
|
metadata: Data;
|
|
@@ -76,7 +76,7 @@ export declare function defineAnswerTaskCatalog<Input, Evidence, App, Data = unk
|
|
|
76
76
|
readerId: string;
|
|
77
77
|
outputId: string;
|
|
78
78
|
scopeId: string | undefined;
|
|
79
|
-
|
|
79
|
+
goalIds: readonly any[];
|
|
80
80
|
checkIds: readonly any[];
|
|
81
81
|
inputSchema: import("../../index.js").SchemaAdapter<Input>;
|
|
82
82
|
metadata: Data;
|
|
@@ -87,7 +87,7 @@ export declare function defineAnswerTaskCatalog<Input, Evidence, App, Data = unk
|
|
|
87
87
|
readerId: string;
|
|
88
88
|
outputId: string;
|
|
89
89
|
scopeId: string | undefined;
|
|
90
|
-
|
|
90
|
+
goalIds: readonly any[];
|
|
91
91
|
checkIds: readonly any[];
|
|
92
92
|
inputSchema: import("../../index.js").SchemaAdapter<Input>;
|
|
93
93
|
metadata: Data;
|
|
@@ -99,7 +99,7 @@ export declare function defineAnswerTaskCatalog<Input, Evidence, App, Data = unk
|
|
|
99
99
|
readerId: string;
|
|
100
100
|
outputId: string;
|
|
101
101
|
scopeId: string | undefined;
|
|
102
|
-
|
|
102
|
+
goalIds: readonly any[];
|
|
103
103
|
checkIds: readonly any[];
|
|
104
104
|
inputSchema: import("../../index.js").SchemaAdapter<Input>;
|
|
105
105
|
metadata: Data;
|
|
@@ -110,7 +110,7 @@ export declare function defineAnswerTaskCatalog<Input, Evidence, App, Data = unk
|
|
|
110
110
|
readerId: string;
|
|
111
111
|
outputId: string;
|
|
112
112
|
scopeId: string | undefined;
|
|
113
|
-
|
|
113
|
+
goalIds: readonly any[];
|
|
114
114
|
checkIds: readonly any[];
|
|
115
115
|
inputSchema: import("../../index.js").SchemaAdapter<Input>;
|
|
116
116
|
metadata: Data;
|
|
@@ -51,10 +51,10 @@ export function defineAnswerTaskCatalog(definitions, ports) {
|
|
|
51
51
|
!definition.description?.trim() ||
|
|
52
52
|
!readers.has(definition.readerId) ||
|
|
53
53
|
!outputs.has(definition.outputId) ||
|
|
54
|
-
!Array.isArray(definition.
|
|
55
|
-
!definition.
|
|
56
|
-
definition.
|
|
57
|
-
new Set(definition.
|
|
54
|
+
!Array.isArray(definition.goalIds) ||
|
|
55
|
+
!definition.goalIds.length ||
|
|
56
|
+
definition.goalIds.some((id) => typeof id !== 'string' || !id.trim()) ||
|
|
57
|
+
new Set(definition.goalIds).size !== definition.goalIds.length ||
|
|
58
58
|
!Array.isArray(definition.checkIds) ||
|
|
59
59
|
new Set(definition.checkIds).size !== definition.checkIds.length ||
|
|
60
60
|
definition.checkIds.some((id) => !checkIds.includes(id)))
|
|
@@ -68,7 +68,7 @@ export function defineAnswerTaskCatalog(definitions, ports) {
|
|
|
68
68
|
readerId: definition.readerId,
|
|
69
69
|
outputId: definition.outputId,
|
|
70
70
|
scopeId: definition.scopeId,
|
|
71
|
-
|
|
71
|
+
goalIds: Object.freeze([...definition.goalIds]),
|
|
72
72
|
checkIds: Object.freeze([...definition.checkIds]),
|
|
73
73
|
inputSchema: snapshotSchemaAdapter(definition.inputSchema),
|
|
74
74
|
metadata,
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { ModelTool } from '../../structs/capabilities/model.js';
|
|
2
|
+
import type { AgentCatalogPorts, CatalogGoal, CatalogScope } from '../../structs/kits/domains/catalog.js';
|
|
3
|
+
/**
|
|
4
|
+
* Compile a catalog projection over the App's live registries.
|
|
5
|
+
*
|
|
6
|
+
* The actual registries determine availability and relationships. No parallel capability list
|
|
7
|
+
* exists: `goalIds` filters by tool support, `modelCatalog` narrows to the currently accepted
|
|
8
|
+
* task when `restrictToTask` is enabled, and scope tool ids are filtered to tools that exist.
|
|
9
|
+
*
|
|
10
|
+
* @param ports - Sources for Tool ids, goals, scopes, the current task, the tool registry
|
|
11
|
+
* and the `restrictToTask` switch.
|
|
12
|
+
* @returns A frozen projection with `goalIds`, `goalDelegates`, `goalCatalog`,
|
|
13
|
+
* `scopeCatalog` and `modelCatalog`.
|
|
14
|
+
* @throws TypeError When a supplied predicate does not return a boolean synchronously.
|
|
15
|
+
*/
|
|
16
|
+
export declare function defineAgentCatalog<App, Id extends string, Goal extends CatalogGoal<Id>, Scope extends CatalogScope>(ports: AgentCatalogPorts<App, Id, Goal, Scope>): Readonly<{
|
|
17
|
+
goalIds: (app: App) => Id[];
|
|
18
|
+
goalDelegates: (app?: App) => Map<Id, string[]>;
|
|
19
|
+
goalCatalog: (app: App) => (Omit<Goal & Partial<ModelTool<unknown, unknown, App>>, "resolve" | "inputSchema" | "active" | "asIntent"> & {
|
|
20
|
+
delegates: string[];
|
|
21
|
+
scopeIds: string[];
|
|
22
|
+
toolIds: string[];
|
|
23
|
+
description?: string | undefined;
|
|
24
|
+
})[];
|
|
25
|
+
scopeCatalog: (app: App) => (Scope & {
|
|
26
|
+
toolIds: string[];
|
|
27
|
+
})[];
|
|
28
|
+
modelCatalog(app: App): {
|
|
29
|
+
availableGoalIds: (Goal & Partial<ModelTool<unknown, unknown, App>>)["id"][];
|
|
30
|
+
availableGoals: (Omit<Goal & Partial<ModelTool<unknown, unknown, App>>, "resolve" | "inputSchema" | "active" | "asIntent"> & {
|
|
31
|
+
delegates: string[];
|
|
32
|
+
scopeIds: string[];
|
|
33
|
+
toolIds: string[];
|
|
34
|
+
description?: string | undefined;
|
|
35
|
+
})[];
|
|
36
|
+
availableScopes: (Scope & {
|
|
37
|
+
toolIds: string[];
|
|
38
|
+
})[];
|
|
39
|
+
availableTools: import("./catalog.js").DescribedTool[];
|
|
40
|
+
};
|
|
41
|
+
}>;
|
|
42
|
+
export type * from '../../structs/kits/domains/catalog.js';
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Domain Tools Kit: project registered goals, scopes and tools into one task-facing catalog.
|
|
3
|
+
*
|
|
4
|
+
* Place in the package: part of the domain Tool Kit. It reads the actual registries supplied by
|
|
5
|
+
* the App instead of maintaining a parallel capability list, so an intent is only advertised
|
|
6
|
+
* when its tools, scopes and availability agree.
|
|
7
|
+
*
|
|
8
|
+
* Exports: `defineAgentCatalog`, and the catalog intent/scope/port types.
|
|
9
|
+
*/
|
|
10
|
+
import { booleanResult } from '../../utils/synchronous.js';
|
|
11
|
+
import { toolActive } from '../../capabilities/tool-conditions.js';
|
|
12
|
+
/**
|
|
13
|
+
* Compile a catalog projection over the App's live registries.
|
|
14
|
+
*
|
|
15
|
+
* The actual registries determine availability and relationships. No parallel capability list
|
|
16
|
+
* exists: `goalIds` filters by tool support, `modelCatalog` narrows to the currently accepted
|
|
17
|
+
* task when `restrictToTask` is enabled, and scope tool ids are filtered to tools that exist.
|
|
18
|
+
*
|
|
19
|
+
* @param ports - Sources for Tool ids, goals, scopes, the current task, the tool registry
|
|
20
|
+
* and the `restrictToTask` switch.
|
|
21
|
+
* @returns A frozen projection with `goalIds`, `goalDelegates`, `goalCatalog`,
|
|
22
|
+
* `scopeCatalog` and `modelCatalog`.
|
|
23
|
+
* @throws TypeError When a supplied predicate does not return a boolean synchronously.
|
|
24
|
+
*/
|
|
25
|
+
export function defineAgentCatalog(ports) {
|
|
26
|
+
const ids = ports.goalIds.bind(ports), goals = ports.goals.bind(ports), scopes = ports.scopes.bind(ports), task = ports.currentTask.bind(ports);
|
|
27
|
+
const tools = {
|
|
28
|
+
values: ports.tools.values.bind(ports.tools),
|
|
29
|
+
has: ports.tools.has.bind(ports.tools),
|
|
30
|
+
supports: ports.tools.supportsGoal.bind(ports.tools),
|
|
31
|
+
describe: ports.tools.describe.bind(ports.tools),
|
|
32
|
+
};
|
|
33
|
+
const restrict = ports.restrictToTask !== false;
|
|
34
|
+
const boolean = (value) => booleanResult(value, 'Catalog predicates must be synchronous', 'Catalog predicates must return boolean');
|
|
35
|
+
/** Whether one goal is active and its demand metadata currently participates. */
|
|
36
|
+
const goalAvailable = (goal, app) => {
|
|
37
|
+
const tool = goal;
|
|
38
|
+
if (!toolActive(tool.active, app))
|
|
39
|
+
return false;
|
|
40
|
+
const metadata = tool.asIntent;
|
|
41
|
+
if (metadata === undefined || metadata === true || typeof metadata === 'string')
|
|
42
|
+
return true;
|
|
43
|
+
if (typeof metadata === 'function')
|
|
44
|
+
return toolActive(metadata, app);
|
|
45
|
+
return toolActive(metadata.when, app);
|
|
46
|
+
};
|
|
47
|
+
const goalIds = (app) => ids(app).filter((id) => boolean(tools.supports(id, app)));
|
|
48
|
+
const goalDelegates = (app) => new Map(goals().map((goal) => {
|
|
49
|
+
const metadata = goal.asIntent;
|
|
50
|
+
const explicit = typeof metadata === 'object' ? metadata.delegates : undefined;
|
|
51
|
+
return [
|
|
52
|
+
goal.id,
|
|
53
|
+
explicit
|
|
54
|
+
? [...explicit]
|
|
55
|
+
: [
|
|
56
|
+
...new Set([
|
|
57
|
+
...goal.delegates,
|
|
58
|
+
...[...tools.values()]
|
|
59
|
+
.filter((tool) => tool.lifecycle?.id &&
|
|
60
|
+
(app === undefined || toolActive(tool.active, app)) &&
|
|
61
|
+
(tool.goalIds === 'all' || tool.goalIds.includes(goal.id)))
|
|
62
|
+
.map((tool) => tool.lifecycle.id),
|
|
63
|
+
]),
|
|
64
|
+
],
|
|
65
|
+
];
|
|
66
|
+
}));
|
|
67
|
+
const goalCatalog = (app) => {
|
|
68
|
+
const selected = goalIds(app), described = tools.describe('model', app), delegates = goalDelegates(app);
|
|
69
|
+
return goals(selected)
|
|
70
|
+
.filter((goal) => goalAvailable(goal, app))
|
|
71
|
+
.map((goal) => {
|
|
72
|
+
const { inputSchema: _schema, resolve: _resolve, active: _active, asIntent: _asIntent, ...metadata } = goal;
|
|
73
|
+
const demandDescription = typeof _asIntent === 'string'
|
|
74
|
+
? _asIntent
|
|
75
|
+
: typeof _asIntent === 'object' && _asIntent !== null
|
|
76
|
+
? _asIntent.description
|
|
77
|
+
: undefined;
|
|
78
|
+
return {
|
|
79
|
+
...metadata,
|
|
80
|
+
...(demandDescription ? { description: demandDescription } : {}),
|
|
81
|
+
delegates: delegates.get(goal.id) ?? [...goal.delegates],
|
|
82
|
+
scopeIds: scopes([goal.id]).map((scope) => scope.id),
|
|
83
|
+
toolIds: described
|
|
84
|
+
.filter((tool) => tool.goalIds.includes(goal.id))
|
|
85
|
+
.map((tool) => tool.id),
|
|
86
|
+
};
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
const scopeCatalog = (app) => scopes(goalCatalog(app).map((goal) => goal.id)).map((scope) => ({
|
|
90
|
+
...scope,
|
|
91
|
+
toolIds: scope.toolIds.filter(tools.has),
|
|
92
|
+
}));
|
|
93
|
+
return Object.freeze({
|
|
94
|
+
goalIds,
|
|
95
|
+
goalDelegates,
|
|
96
|
+
goalCatalog,
|
|
97
|
+
scopeCatalog,
|
|
98
|
+
modelCatalog(app) {
|
|
99
|
+
const accepted = restrict ? task(app) : undefined, selected = goalIds(app).filter((id) => !accepted || id === accepted.goalId), available = goalCatalog(app).filter((intent) => selected.includes(intent.id));
|
|
100
|
+
return {
|
|
101
|
+
availableGoalIds: available.map((intent) => intent.id),
|
|
102
|
+
availableGoals: available.map((intent) => accepted ? { ...intent, scopeIds: accepted.scopeId ? [accepted.scopeId] : [] } : intent),
|
|
103
|
+
availableScopes: scopeCatalog(app).filter((scope) => !accepted || scope.id === accepted.scopeId),
|
|
104
|
+
availableTools: tools
|
|
105
|
+
.describe('model', app)
|
|
106
|
+
.filter((tool) => !accepted || tool.goalIds.includes(accepted.goalId)),
|
|
107
|
+
};
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Domain Tools Kit: an ordered, sealable registry of domain Tool declarations.
|
|
3
|
+
*
|
|
4
|
+
* Place in the package: part of the domain Tool Kit. Goal semantics and the allowed vocabulary
|
|
5
|
+
* (scope modes, target modes, context tiers, delegates, actions) are App configuration; this class
|
|
6
|
+
* owns the common lifecycle — validation, ordering, duplicate detection and sealing.
|
|
7
|
+
*
|
|
8
|
+
* Exports: `IntentRegistry`, `createIntentRegistry`, and the domain Tool registry types.
|
|
9
|
+
*/
|
|
10
|
+
import type { IntentTool, IntentToolRegistration, IntentDescription, IntentPolicy, IntentId, RegisteredIntent } from '../../structs/kits/domains/registry.js';
|
|
11
|
+
import { ModelToolRegistry } from '../../capabilities/model.js';
|
|
12
|
+
/**
|
|
13
|
+
* Goal semantics and allowed values are configuration; the registry owns their common lifecycle.
|
|
14
|
+
*
|
|
15
|
+
* Registration order is preserved by `ids`, `definitions`, `values` and `entries`; once
|
|
16
|
+
* `seal()` is called the set is final and further registration is rejected.
|
|
17
|
+
*/
|
|
18
|
+
export declare class IntentRegistry<Definition extends IntentToolRegistration = IntentToolRegistration> {
|
|
19
|
+
/** Create and seal a complete catalog in one call. */
|
|
20
|
+
static readonly create: typeof createIntentRegistry;
|
|
21
|
+
private readonly byId;
|
|
22
|
+
private sealed;
|
|
23
|
+
private modelView?;
|
|
24
|
+
private readonly policy;
|
|
25
|
+
/**
|
|
26
|
+
* @param policy - Optional id pattern, vocabulary lists, error wording and assertion hook.
|
|
27
|
+
* Lists and the pattern are copied so later mutation of the input cannot weaken checks.
|
|
28
|
+
*/
|
|
29
|
+
constructor(policy?: IntentPolicy<Definition>);
|
|
30
|
+
/**
|
|
31
|
+
* Validate, freeze and add one domain Tool.
|
|
32
|
+
*
|
|
33
|
+
* Checks run in a fixed order — sealed, identity, context contract, auxiliary actions,
|
|
34
|
+
* handoff, plan, delegates — so the reported violation is stable when several rules fail.
|
|
35
|
+
*
|
|
36
|
+
* @param input - Goal declaration; the App's own assertion receives this original object,
|
|
37
|
+
* not the compiled copy, so helpers and prototype methods keep working.
|
|
38
|
+
* @returns This registry, for chaining.
|
|
39
|
+
* @throws A configured error for a sealed registry, invalid identity or vocabulary values,
|
|
40
|
+
* empty/duplicate delegates, or a duplicate Tool id.
|
|
41
|
+
*/
|
|
42
|
+
register(input: Definition): this;
|
|
43
|
+
/** Register every domain Tool in iteration order. */
|
|
44
|
+
registerAll(definitions: Iterable<Definition>): this;
|
|
45
|
+
/** Registered domain Tool for `id`, or `undefined` when it is absent. */
|
|
46
|
+
get(goal: string): RegisteredIntent<Definition> | undefined;
|
|
47
|
+
/** Whether a Tool id is registered. */
|
|
48
|
+
has(goal: string): boolean;
|
|
49
|
+
/** Registered Tool ids in registration order. */
|
|
50
|
+
ids(): readonly IntentId<Definition>[];
|
|
51
|
+
/** Registered goals in registration order. */
|
|
52
|
+
get definitions(): readonly RegisteredIntent<Definition>[];
|
|
53
|
+
/** Iterate the registered goals. */
|
|
54
|
+
values(): MapIterator<Readonly<Omit<Readonly<IntentTool & import("../../utils/registration.js").RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof IntentTool>>>, "resolve" | "inputSchema" | "delegates" | "auxiliaryActions"> & import("../../index.js").ModelTool<any, any, any> & { readonly [Key in keyof Pick<Definition, Extract<keyof Definition, "delegates" | "auxiliaryActions">>]: Readonly<Definition[Key]>; } & {
|
|
55
|
+
id: Definition["id"];
|
|
56
|
+
delegates: Readonly<NonNullable<Definition["delegates"]>>;
|
|
57
|
+
}>>;
|
|
58
|
+
/** Demand discovery uses tool metadata; domain fields remain attached to these same IDs. */
|
|
59
|
+
withIntent(context: unknown): ModelToolRegistry;
|
|
60
|
+
/** Resolve a grouped transport's selected Tool through that Tool's own parser and resolver. */
|
|
61
|
+
resolve(selection: import('../../structs/capabilities/model.js').ModelSelection, context: Readonly<{
|
|
62
|
+
stageId: string;
|
|
63
|
+
}>): unknown;
|
|
64
|
+
/** Explicit node selection uses the same immutable model projection. */
|
|
65
|
+
select(ids: readonly string[], ...context: [] | [unknown]): ModelToolRegistry;
|
|
66
|
+
/** Cache only immutable declarations; request activation is evaluated by each projection. */
|
|
67
|
+
private models;
|
|
68
|
+
/** Iterate `[id, tool]` pairs. */
|
|
69
|
+
entries(): MapIterator<[string, Readonly<Omit<Readonly<IntentTool & import("../../utils/registration.js").RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof IntentTool>>>, "resolve" | "inputSchema" | "delegates" | "auxiliaryActions"> & import("../../index.js").ModelTool<any, any, any> & { readonly [Key in keyof Pick<Definition, Extract<keyof Definition, "delegates" | "auxiliaryActions">>]: Readonly<Definition[Key]>; } & {
|
|
70
|
+
id: Definition["id"];
|
|
71
|
+
delegates: Readonly<NonNullable<Definition["delegates"]>>;
|
|
72
|
+
}>]>;
|
|
73
|
+
/**
|
|
74
|
+
* Registered domain Tool for `id`.
|
|
75
|
+
*
|
|
76
|
+
* @throws TypeError When the id is not registered.
|
|
77
|
+
*/
|
|
78
|
+
require(id: string): RegisteredIntent<Definition>;
|
|
79
|
+
/** Whether the Tool declares this delegate; unknown goals allow nothing. */
|
|
80
|
+
allows(goal: string, delegate: string): boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Copy the selected goals out of the registry.
|
|
83
|
+
*
|
|
84
|
+
* @param goals - Ids to include; the default is every registered id, in registry order.
|
|
85
|
+
* @returns Descriptions whose arrays are copied so callers cannot mutate registry state.
|
|
86
|
+
*/
|
|
87
|
+
describe(goals?: readonly string[]): IntentDescription<Definition>[];
|
|
88
|
+
/** Finalize the registry; no registration is accepted afterwards. */
|
|
89
|
+
seal(): this;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Create and seal a complete catalog; use the constructor for incremental installation.
|
|
93
|
+
*
|
|
94
|
+
* @param definitions - Goal declarations registered in iteration order.
|
|
95
|
+
* @param policy - Optional registry policy forwarded to the constructor.
|
|
96
|
+
* @returns A sealed registry.
|
|
97
|
+
* @throws A configured error for the first invalid or duplicate declaration.
|
|
98
|
+
*/
|
|
99
|
+
export declare function createIntentRegistry<Definition extends IntentToolRegistration>(definitions: Iterable<Definition>, policy?: IntentPolicy<Definition>): IntentRegistry<Definition>;
|
|
100
|
+
export type { IntentTool, IntentToolRegistration, IntentDescription, IntentPolicy, IntentId, RegisteredIntent, } from '../../structs/kits/domains/registry.js';
|