@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
|
@@ -1,30 +0,0 @@
|
|
|
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
|
-
exports.ValidationError = exports.BudgetError = void 0;
|
|
18
|
-
/**
|
|
19
|
-
* Public surface of the execution layer.
|
|
20
|
-
*
|
|
21
|
-
* Re-exports the engine, the workflow catalog and its route helpers, the shared budget
|
|
22
|
-
* and validation errors, and the policy kit. Applications should import the loop and
|
|
23
|
-
* workflow contracts from here rather than from individual files.
|
|
24
|
-
*/
|
|
25
|
-
__exportStar(require("./engine.js"), exports);
|
|
26
|
-
__exportStar(require("./workflow.js"), exports);
|
|
27
|
-
var errors_js_1 = require("../structs/errors.js");
|
|
28
|
-
Object.defineProperty(exports, "BudgetError", { enumerable: true, get: function () { return errors_js_1.BudgetError; } });
|
|
29
|
-
Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return errors_js_1.ValidationError; } });
|
|
30
|
-
__exportStar(require("../kits/policies.js"), exports);
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.defineAgentCatalog = defineAgentCatalog;
|
|
4
|
-
/**
|
|
5
|
-
* Intents Kit: project registered intents, scopes and tools into one task-facing catalog.
|
|
6
|
-
*
|
|
7
|
-
* Place in the package: part of the `intents` 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
|
-
/**
|
|
15
|
-
* Compile a catalog projection over the App's live registries.
|
|
16
|
-
*
|
|
17
|
-
* The actual registries determine availability and relationships. No parallel capability list
|
|
18
|
-
* exists: `intentIds` filters by tool support, `modelCatalog` narrows to the currently accepted
|
|
19
|
-
* task when `restrictToTask` is enabled, and scope tool ids are filtered to tools that exist.
|
|
20
|
-
*
|
|
21
|
-
* @param ports - Sources for intent ids, intents, scopes, the current task, the tool registry
|
|
22
|
-
* and the `restrictToTask` switch.
|
|
23
|
-
* @returns A frozen projection with `intentIds`, `intentSteps`, `intentCatalog`,
|
|
24
|
-
* `scopeCatalog` and `modelCatalog`.
|
|
25
|
-
* @throws TypeError When a supplied predicate does not return a boolean synchronously.
|
|
26
|
-
*/
|
|
27
|
-
function defineAgentCatalog(ports) {
|
|
28
|
-
const ids = ports.intentIds.bind(ports), intents = ports.intents.bind(ports), scopes = ports.scopes.bind(ports), task = ports.currentTask.bind(ports);
|
|
29
|
-
const tools = {
|
|
30
|
-
values: ports.tools.values.bind(ports.tools),
|
|
31
|
-
has: ports.tools.has.bind(ports.tools),
|
|
32
|
-
supports: ports.tools.supportsIntent.bind(ports.tools),
|
|
33
|
-
describe: ports.tools.describe.bind(ports.tools),
|
|
34
|
-
};
|
|
35
|
-
const restrict = ports.restrictToTask !== false;
|
|
36
|
-
const boolean = (value) => (0, synchronous_js_1.booleanResult)(value, 'Catalog predicates must be synchronous', 'Catalog predicates must return boolean');
|
|
37
|
-
const intentIds = (app) => ids().filter((id) => boolean(tools.supports(id, app)));
|
|
38
|
-
const intentSteps = (app) => new Map(intents().map((intent) => [
|
|
39
|
-
intent.id,
|
|
40
|
-
[
|
|
41
|
-
...new Set([
|
|
42
|
-
...intent.steps,
|
|
43
|
-
...[...tools.values()]
|
|
44
|
-
.filter((tool) => tool.invocation &&
|
|
45
|
-
(!tool.available || app === undefined || boolean(tool.available(app))) &&
|
|
46
|
-
(tool.intentIds === 'all' || tool.intentIds.includes(intent.id)))
|
|
47
|
-
.map((tool) => tool.invocation.step),
|
|
48
|
-
]),
|
|
49
|
-
],
|
|
50
|
-
]));
|
|
51
|
-
const intentCatalog = (app) => {
|
|
52
|
-
const selected = intentIds(app), described = tools.describe('model', app), steps = intentSteps(app);
|
|
53
|
-
return intents(selected).map((intent) => ({
|
|
54
|
-
...intent,
|
|
55
|
-
steps: steps.get(intent.id) ?? [...intent.steps],
|
|
56
|
-
scopeIds: scopes([intent.id]).map((scope) => scope.id),
|
|
57
|
-
toolIds: described
|
|
58
|
-
.filter((tool) => tool.intentIds.includes(intent.id))
|
|
59
|
-
.map((tool) => tool.id),
|
|
60
|
-
}));
|
|
61
|
-
};
|
|
62
|
-
const scopeCatalog = (app) => scopes(intentIds(app)).map((scope) => ({ ...scope, toolIds: scope.toolIds.filter(tools.has) }));
|
|
63
|
-
return Object.freeze({
|
|
64
|
-
intentIds,
|
|
65
|
-
intentSteps,
|
|
66
|
-
intentCatalog,
|
|
67
|
-
scopeCatalog,
|
|
68
|
-
modelCatalog(app) {
|
|
69
|
-
const accepted = restrict ? task(app) : undefined, selected = intentIds(app).filter((id) => !accepted || id === accepted.intentId);
|
|
70
|
-
return {
|
|
71
|
-
availableIntentIds: selected,
|
|
72
|
-
availableIntents: intentCatalog(app)
|
|
73
|
-
.filter((intent) => selected.includes(intent.id))
|
|
74
|
-
.map((intent) => accepted ? { ...intent, scopeIds: accepted.scopeId ? [accepted.scopeId] : [] } : intent),
|
|
75
|
-
availableScopes: scopeCatalog(app).filter((scope) => !accepted || scope.id === accepted.scopeId),
|
|
76
|
-
availableTools: tools
|
|
77
|
-
.describe('model', app)
|
|
78
|
-
.filter((tool) => !accepted || tool.intentIds.includes(accepted.intentId)),
|
|
79
|
-
};
|
|
80
|
-
},
|
|
81
|
-
});
|
|
82
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
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
|
-
exports.Intents = void 0;
|
|
18
|
-
/**
|
|
19
|
-
* Intents Kit entry: intent and scope registries plus the task-facing catalog projection.
|
|
20
|
-
*
|
|
21
|
-
* Place in the package: an optional App-side library for declaring what the agent may do.
|
|
22
|
-
* Applications register their own intents and scopes; this directory owns registration
|
|
23
|
-
* checks, aliases, relationship lookups and the model-visible projection. Core never imports it.
|
|
24
|
-
*
|
|
25
|
-
* Exports: everything from `./registry.js`, `./scopes.js` and `./catalog.js`, plus the
|
|
26
|
-
* `Intents` namespace object.
|
|
27
|
-
*/
|
|
28
|
-
__exportStar(require("./registry.js"), exports);
|
|
29
|
-
__exportStar(require("./scopes.js"), exports);
|
|
30
|
-
__exportStar(require("./catalog.js"), exports);
|
|
31
|
-
const registry_js_1 = require("./registry.js");
|
|
32
|
-
const scopes_js_1 = require("./scopes.js");
|
|
33
|
-
const catalog_js_1 = require("./catalog.js");
|
|
34
|
-
/** Namespace object for callers that prefer one import over named helpers. */
|
|
35
|
-
exports.Intents = Object.freeze({ IntentRegistry: registry_js_1.IntentRegistry, ScopeRegistry: scopes_js_1.ScopeRegistry, defineAgentCatalog: catalog_js_1.defineAgentCatalog });
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Public surface of the execution layer.
|
|
3
|
-
*
|
|
4
|
-
* Re-exports the engine, the workflow catalog and its route helpers, the shared budget
|
|
5
|
-
* and validation errors, and the policy kit. Applications should import the loop and
|
|
6
|
-
* workflow contracts from here rather than from individual files.
|
|
7
|
-
*/
|
|
8
|
-
export * from './engine.js';
|
|
9
|
-
export * from './workflow.js';
|
|
10
|
-
export { BudgetError, ValidationError } from '../structs/errors.js';
|
|
11
|
-
export * from '../kits/policies.js';
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Public surface of the execution layer.
|
|
3
|
-
*
|
|
4
|
-
* Re-exports the engine, the workflow catalog and its route helpers, the shared budget
|
|
5
|
-
* and validation errors, and the policy kit. Applications should import the loop and
|
|
6
|
-
* workflow contracts from here rather than from individual files.
|
|
7
|
-
*/
|
|
8
|
-
export * from './engine.js';
|
|
9
|
-
export * from './workflow.js';
|
|
10
|
-
export { BudgetError, ValidationError } from '../structs/errors.js';
|
|
11
|
-
export * from '../kits/policies.js';
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { AgentCatalogPorts, CatalogIntent, CatalogScope } from '../../structs/kits/intents/catalog.js';
|
|
2
|
-
/**
|
|
3
|
-
* Compile a catalog projection over the App's live registries.
|
|
4
|
-
*
|
|
5
|
-
* The actual registries determine availability and relationships. No parallel capability list
|
|
6
|
-
* exists: `intentIds` filters by tool support, `modelCatalog` narrows to the currently accepted
|
|
7
|
-
* task when `restrictToTask` is enabled, and scope tool ids are filtered to tools that exist.
|
|
8
|
-
*
|
|
9
|
-
* @param ports - Sources for intent ids, intents, scopes, the current task, the tool registry
|
|
10
|
-
* and the `restrictToTask` switch.
|
|
11
|
-
* @returns A frozen projection with `intentIds`, `intentSteps`, `intentCatalog`,
|
|
12
|
-
* `scopeCatalog` and `modelCatalog`.
|
|
13
|
-
* @throws TypeError When a supplied predicate does not return a boolean synchronously.
|
|
14
|
-
*/
|
|
15
|
-
export declare function defineAgentCatalog<App, Id extends string, Intent extends CatalogIntent<Id>, Scope extends CatalogScope>(ports: AgentCatalogPorts<App, Id, Intent, Scope>): Readonly<{
|
|
16
|
-
intentIds: (app: App) => Id[];
|
|
17
|
-
intentSteps: (app?: App) => Map<Id, string[]>;
|
|
18
|
-
intentCatalog: (app: App) => (Intent & {
|
|
19
|
-
steps: string[];
|
|
20
|
-
scopeIds: string[];
|
|
21
|
-
toolIds: string[];
|
|
22
|
-
})[];
|
|
23
|
-
scopeCatalog: (app: App) => (Scope & {
|
|
24
|
-
toolIds: string[];
|
|
25
|
-
})[];
|
|
26
|
-
modelCatalog(app: App): {
|
|
27
|
-
availableIntentIds: Id[];
|
|
28
|
-
availableIntents: (Intent & {
|
|
29
|
-
steps: string[];
|
|
30
|
-
scopeIds: string[];
|
|
31
|
-
toolIds: string[];
|
|
32
|
-
})[];
|
|
33
|
-
availableScopes: (Scope & {
|
|
34
|
-
toolIds: string[];
|
|
35
|
-
})[];
|
|
36
|
-
availableTools: import("./catalog.js").DescribedTool[];
|
|
37
|
-
};
|
|
38
|
-
}>;
|
|
39
|
-
export type * from '../../structs/kits/intents/catalog.js';
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Intents Kit: project registered intents, scopes and tools into one task-facing catalog.
|
|
3
|
-
*
|
|
4
|
-
* Place in the package: part of the `intents` 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
|
-
/**
|
|
12
|
-
* Compile a catalog projection over the App's live registries.
|
|
13
|
-
*
|
|
14
|
-
* The actual registries determine availability and relationships. No parallel capability list
|
|
15
|
-
* exists: `intentIds` filters by tool support, `modelCatalog` narrows to the currently accepted
|
|
16
|
-
* task when `restrictToTask` is enabled, and scope tool ids are filtered to tools that exist.
|
|
17
|
-
*
|
|
18
|
-
* @param ports - Sources for intent ids, intents, scopes, the current task, the tool registry
|
|
19
|
-
* and the `restrictToTask` switch.
|
|
20
|
-
* @returns A frozen projection with `intentIds`, `intentSteps`, `intentCatalog`,
|
|
21
|
-
* `scopeCatalog` and `modelCatalog`.
|
|
22
|
-
* @throws TypeError When a supplied predicate does not return a boolean synchronously.
|
|
23
|
-
*/
|
|
24
|
-
export function defineAgentCatalog(ports) {
|
|
25
|
-
const ids = ports.intentIds.bind(ports), intents = ports.intents.bind(ports), scopes = ports.scopes.bind(ports), task = ports.currentTask.bind(ports);
|
|
26
|
-
const tools = {
|
|
27
|
-
values: ports.tools.values.bind(ports.tools),
|
|
28
|
-
has: ports.tools.has.bind(ports.tools),
|
|
29
|
-
supports: ports.tools.supportsIntent.bind(ports.tools),
|
|
30
|
-
describe: ports.tools.describe.bind(ports.tools),
|
|
31
|
-
};
|
|
32
|
-
const restrict = ports.restrictToTask !== false;
|
|
33
|
-
const boolean = (value) => booleanResult(value, 'Catalog predicates must be synchronous', 'Catalog predicates must return boolean');
|
|
34
|
-
const intentIds = (app) => ids().filter((id) => boolean(tools.supports(id, app)));
|
|
35
|
-
const intentSteps = (app) => new Map(intents().map((intent) => [
|
|
36
|
-
intent.id,
|
|
37
|
-
[
|
|
38
|
-
...new Set([
|
|
39
|
-
...intent.steps,
|
|
40
|
-
...[...tools.values()]
|
|
41
|
-
.filter((tool) => tool.invocation &&
|
|
42
|
-
(!tool.available || app === undefined || boolean(tool.available(app))) &&
|
|
43
|
-
(tool.intentIds === 'all' || tool.intentIds.includes(intent.id)))
|
|
44
|
-
.map((tool) => tool.invocation.step),
|
|
45
|
-
]),
|
|
46
|
-
],
|
|
47
|
-
]));
|
|
48
|
-
const intentCatalog = (app) => {
|
|
49
|
-
const selected = intentIds(app), described = tools.describe('model', app), steps = intentSteps(app);
|
|
50
|
-
return intents(selected).map((intent) => ({
|
|
51
|
-
...intent,
|
|
52
|
-
steps: steps.get(intent.id) ?? [...intent.steps],
|
|
53
|
-
scopeIds: scopes([intent.id]).map((scope) => scope.id),
|
|
54
|
-
toolIds: described
|
|
55
|
-
.filter((tool) => tool.intentIds.includes(intent.id))
|
|
56
|
-
.map((tool) => tool.id),
|
|
57
|
-
}));
|
|
58
|
-
};
|
|
59
|
-
const scopeCatalog = (app) => scopes(intentIds(app)).map((scope) => ({ ...scope, toolIds: scope.toolIds.filter(tools.has) }));
|
|
60
|
-
return Object.freeze({
|
|
61
|
-
intentIds,
|
|
62
|
-
intentSteps,
|
|
63
|
-
intentCatalog,
|
|
64
|
-
scopeCatalog,
|
|
65
|
-
modelCatalog(app) {
|
|
66
|
-
const accepted = restrict ? task(app) : undefined, selected = intentIds(app).filter((id) => !accepted || id === accepted.intentId);
|
|
67
|
-
return {
|
|
68
|
-
availableIntentIds: selected,
|
|
69
|
-
availableIntents: intentCatalog(app)
|
|
70
|
-
.filter((intent) => selected.includes(intent.id))
|
|
71
|
-
.map((intent) => accepted ? { ...intent, scopeIds: accepted.scopeId ? [accepted.scopeId] : [] } : intent),
|
|
72
|
-
availableScopes: scopeCatalog(app).filter((scope) => !accepted || scope.id === accepted.scopeId),
|
|
73
|
-
availableTools: tools
|
|
74
|
-
.describe('model', app)
|
|
75
|
-
.filter((tool) => !accepted || tool.intentIds.includes(accepted.intentId)),
|
|
76
|
-
};
|
|
77
|
-
},
|
|
78
|
-
});
|
|
79
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Intents Kit entry: intent and scope registries plus the task-facing catalog projection.
|
|
3
|
-
*
|
|
4
|
-
* Place in the package: an optional App-side library for declaring what the agent may do.
|
|
5
|
-
* Applications register their own intents and scopes; this directory owns registration
|
|
6
|
-
* checks, aliases, relationship lookups and the model-visible projection. Core never imports it.
|
|
7
|
-
*
|
|
8
|
-
* Exports: everything from `./registry.js`, `./scopes.js` and `./catalog.js`, plus the
|
|
9
|
-
* `Intents` namespace object.
|
|
10
|
-
*/
|
|
11
|
-
export * from './registry.js';
|
|
12
|
-
export * from './scopes.js';
|
|
13
|
-
export * from './catalog.js';
|
|
14
|
-
import { IntentRegistry } from './registry.js';
|
|
15
|
-
import { ScopeRegistry } from './scopes.js';
|
|
16
|
-
import { defineAgentCatalog } from './catalog.js';
|
|
17
|
-
/** Namespace object for callers that prefer one import over named helpers. */
|
|
18
|
-
export declare const Intents: Readonly<{
|
|
19
|
-
IntentRegistry: typeof IntentRegistry;
|
|
20
|
-
ScopeRegistry: typeof ScopeRegistry;
|
|
21
|
-
defineAgentCatalog: typeof defineAgentCatalog;
|
|
22
|
-
}>;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Intents Kit entry: intent and scope registries plus the task-facing catalog projection.
|
|
3
|
-
*
|
|
4
|
-
* Place in the package: an optional App-side library for declaring what the agent may do.
|
|
5
|
-
* Applications register their own intents and scopes; this directory owns registration
|
|
6
|
-
* checks, aliases, relationship lookups and the model-visible projection. Core never imports it.
|
|
7
|
-
*
|
|
8
|
-
* Exports: everything from `./registry.js`, `./scopes.js` and `./catalog.js`, plus the
|
|
9
|
-
* `Intents` namespace object.
|
|
10
|
-
*/
|
|
11
|
-
export * from './registry.js';
|
|
12
|
-
export * from './scopes.js';
|
|
13
|
-
export * from './catalog.js';
|
|
14
|
-
import { IntentRegistry } from './registry.js';
|
|
15
|
-
import { ScopeRegistry } from './scopes.js';
|
|
16
|
-
import { defineAgentCatalog } from './catalog.js';
|
|
17
|
-
/** Namespace object for callers that prefer one import over named helpers. */
|
|
18
|
-
export const Intents = Object.freeze({ IntentRegistry, ScopeRegistry, defineAgentCatalog });
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Intents Kit: an ordered, sealable registry of intent declarations.
|
|
3
|
-
*
|
|
4
|
-
* Place in the package: part of the `intents` Kit. Intent semantics and the allowed vocabulary
|
|
5
|
-
* (scope modes, target modes, context tiers, steps, actions) are App configuration; this class
|
|
6
|
-
* owns the common lifecycle — validation, ordering, duplicate detection and sealing.
|
|
7
|
-
*
|
|
8
|
-
* Exports: `IntentRegistry`, `createIntentRegistry`, and the intent registry types.
|
|
9
|
-
*/
|
|
10
|
-
import type { IntentDefinition, IntentDescription, IntentRegistryPolicy, IntentId, RegisteredIntent } from '../../structs/kits/intents/registry.js';
|
|
11
|
-
/**
|
|
12
|
-
* Intent semantics and allowed values are configuration; the registry owns their common lifecycle.
|
|
13
|
-
*
|
|
14
|
-
* Registration order is preserved by `ids`, `definitions`, `values` and `entries`; once
|
|
15
|
-
* `seal()` is called the set is final and further registration is rejected.
|
|
16
|
-
*/
|
|
17
|
-
export declare class IntentRegistry<Definition extends IntentDefinition = IntentDefinition> {
|
|
18
|
-
/** Create and seal a complete catalog in one call. */
|
|
19
|
-
static readonly create: typeof createIntentRegistry;
|
|
20
|
-
private readonly byId;
|
|
21
|
-
private sealed;
|
|
22
|
-
private readonly policy;
|
|
23
|
-
/**
|
|
24
|
-
* @param policy - Optional id pattern, vocabulary lists, error wording and assertion hook.
|
|
25
|
-
* Lists and the pattern are copied so later mutation of the input cannot weaken checks.
|
|
26
|
-
*/
|
|
27
|
-
constructor(policy?: IntentRegistryPolicy<Definition>);
|
|
28
|
-
/**
|
|
29
|
-
* Validate, freeze and add one intent.
|
|
30
|
-
*
|
|
31
|
-
* Checks run in a fixed order — sealed, identity, context contract, auxiliary actions,
|
|
32
|
-
* handoff, plan, steps — so the reported violation is stable when several rules fail.
|
|
33
|
-
*
|
|
34
|
-
* @param input - Intent declaration; the App's own assertion receives this original object,
|
|
35
|
-
* not the compiled copy, so helpers and prototype methods keep working.
|
|
36
|
-
* @returns This registry, for chaining.
|
|
37
|
-
* @throws A configured error for a sealed registry, invalid identity or vocabulary values,
|
|
38
|
-
* empty/duplicate steps, or a duplicate intent id.
|
|
39
|
-
*/
|
|
40
|
-
register(input: Definition): this;
|
|
41
|
-
/** Register every intent in iteration order. */
|
|
42
|
-
registerAll(definitions: Iterable<Definition>): this;
|
|
43
|
-
/** Registered intent for `goal`, or `undefined` when it is absent. */
|
|
44
|
-
get(goal: string): RegisteredIntent<Definition> | undefined;
|
|
45
|
-
/** Whether an intent id is registered. */
|
|
46
|
-
has(goal: string): boolean;
|
|
47
|
-
/** Registered intent ids in registration order. */
|
|
48
|
-
ids(): readonly IntentId<Definition>[];
|
|
49
|
-
/** Registered intents in registration order. */
|
|
50
|
-
get definitions(): readonly RegisteredIntent<Definition>[];
|
|
51
|
-
/** Iterate the registered intents. */
|
|
52
|
-
values(): MapIterator<Readonly<Omit<Readonly<IntentDefinition & import("../../utils/registration.js").RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof IntentDefinition>>>, "steps" | "auxiliaryActions"> & { readonly [Key in keyof Pick<Definition, Extract<keyof Definition, "steps" | "auxiliaryActions">>]: Readonly<Definition[Key]>; } & {
|
|
53
|
-
id: Definition["id"];
|
|
54
|
-
steps: Readonly<Definition["steps"]>;
|
|
55
|
-
}>>;
|
|
56
|
-
/** Iterate `[id, intent]` pairs. */
|
|
57
|
-
entries(): MapIterator<[string, Readonly<Omit<Readonly<IntentDefinition & import("../../utils/registration.js").RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof IntentDefinition>>>, "steps" | "auxiliaryActions"> & { readonly [Key in keyof Pick<Definition, Extract<keyof Definition, "steps" | "auxiliaryActions">>]: Readonly<Definition[Key]>; } & {
|
|
58
|
-
id: Definition["id"];
|
|
59
|
-
steps: Readonly<Definition["steps"]>;
|
|
60
|
-
}>]>;
|
|
61
|
-
/**
|
|
62
|
-
* Registered intent for `id`.
|
|
63
|
-
*
|
|
64
|
-
* @throws TypeError When the id is not registered.
|
|
65
|
-
*/
|
|
66
|
-
require(id: string): RegisteredIntent<Definition>;
|
|
67
|
-
/** Whether the intent declares this step; unknown intents allow nothing. */
|
|
68
|
-
allows(goal: string, step: string): boolean;
|
|
69
|
-
/**
|
|
70
|
-
* Copy the selected intents out of the registry.
|
|
71
|
-
*
|
|
72
|
-
* @param goals - Ids to include; the default is every registered id, in registry order.
|
|
73
|
-
* @returns Descriptions whose arrays are copied so callers cannot mutate registry state.
|
|
74
|
-
*/
|
|
75
|
-
describe(goals?: readonly string[]): IntentDescription<Definition>[];
|
|
76
|
-
/** Finalize the registry; no registration is accepted afterwards. */
|
|
77
|
-
seal(): this;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Create and seal a complete catalog; use the constructor for incremental installation.
|
|
81
|
-
*
|
|
82
|
-
* @param definitions - Intent declarations registered in iteration order.
|
|
83
|
-
* @param policy - Optional registry policy forwarded to the constructor.
|
|
84
|
-
* @returns A sealed registry.
|
|
85
|
-
* @throws A configured error for the first invalid or duplicate declaration.
|
|
86
|
-
*/
|
|
87
|
-
export declare function createIntentRegistry<Definition extends IntentDefinition>(definitions: Iterable<Definition>, policy?: IntentRegistryPolicy<Definition>): IntentRegistry<Definition>;
|
|
88
|
-
export type { IntentDefinition, IntentDescription, IntentRegistryPolicy, IntentId, RegisteredIntent, } from '../../structs/kits/intents/registry.js';
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|