@bizagent/dsh 0.0.0-stage → 1.0.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 +124 -0
- package/LICENSE +21 -0
- package/README.md +61 -2
- package/cordis.patch.yml +14 -0
- package/docs/README.md +23 -0
- package/docs/architecture.md +154 -0
- package/docs/concepts.md +192 -0
- package/docs/configuration.md +154 -0
- package/docs/quickstart.md +103 -0
- package/docs/quickstart.zh-CN.md +86 -0
- package/docs/tools.md +607 -0
- package/docs/user-guide.zh-CN.md +132 -0
- package/docs/verification.md +69 -0
- package/examples/README.md +64 -0
- package/examples/demo-runtime.mjs +71 -0
- package/examples/learning-lab.mjs +263 -0
- package/examples/scenarios.mjs +45 -0
- package/lib/agent-preset.d.ts +20 -0
- package/lib/agent-preset.js +46 -0
- package/lib/agent-session-address.d.ts +14 -0
- package/lib/agent-session-address.js +15 -0
- package/lib/agent-session-coordinator.d.ts +24 -0
- package/lib/agent-session-coordinator.js +101 -0
- package/lib/cli.d.ts +3 -0
- package/lib/cli.js +142 -0
- package/lib/client-types/agent-session-address.d.ts +13 -0
- package/lib/client-types/client/agent-mentions.d.ts +3 -0
- package/lib/client-types/client/api.d.ts +180 -0
- package/lib/client-types/client/components.d.ts +22 -0
- package/lib/client-types/client/controller.d.ts +23 -0
- package/lib/client-types/client/frame-participants.d.ts +5 -0
- package/lib/client-types/client/home-name.d.ts +9 -0
- package/lib/client-types/client/human-inbox.d.ts +8 -0
- package/lib/client-types/client/index.d.ts +13 -0
- package/lib/client-types/client/locales.d.ts +796 -0
- package/lib/client-types/client/markdown.d.ts +12 -0
- package/lib/client-types/client/project-artifact-link.d.ts +10 -0
- package/lib/client-types/client/project-outcome-review-inbox.d.ts +13 -0
- package/lib/client-types/client/projects.d.ts +11 -0
- package/lib/client-types/client/sample-guide.d.ts +9 -0
- package/lib/client-types/client/session-resource.d.ts +34 -0
- package/lib/client-types/client/session-surfaces.d.ts +24 -0
- package/lib/client-types/client/styles.d.ts +1 -0
- package/lib/client-types/config.d.ts +55 -0
- package/lib/client-types/cron.d.ts +8 -0
- package/lib/client-types/domain.d.ts +818 -0
- package/lib/client-types/frame-reference.d.ts +4 -0
- package/lib/client-types/home-directory.d.ts +5 -0
- package/lib/client-types/home-space.d.ts +49 -0
- package/lib/client-types/home-store.d.ts +125 -0
- package/lib/client-types/inbox-stalled-topic.d.ts +15 -0
- package/lib/client-types/inbox-wake-policy.d.ts +18 -0
- package/lib/client-types/known-format.d.ts +2 -0
- package/lib/client-types/learning-scheduler.d.ts +36 -0
- package/lib/client-types/learning-session-runner.d.ts +49 -0
- package/lib/client-types/learning-trigger.d.ts +17 -0
- package/lib/client-types/learning-usage.d.ts +17 -0
- package/lib/client-types/ledger.d.ts +190 -0
- package/lib/client-types/local-owner.d.ts +7 -0
- package/lib/client-types/message-source.d.ts +9 -0
- package/lib/client-types/organization-location.d.ts +19 -0
- package/lib/client-types/project-ledger.d.ts +182 -0
- package/lib/client-types/project-seat-context.d.ts +17 -0
- package/lib/client-types/safe-file.d.ts +23 -0
- package/lib/client-types/sample-organization.d.ts +9 -0
- package/lib/client-types/service.d.ts +596 -0
- package/lib/client-types/shared-knowledge.d.ts +116 -0
- package/lib/client-types/ui-contract.d.ts +276 -0
- package/lib/client-types/untrusted-text.d.ts +15 -0
- package/lib/client-types/work-ledger.d.ts +108 -0
- package/lib/client-types/work-output-eval.d.ts +15 -0
- package/lib/client-types/worklog-ledger.d.ts +88 -0
- package/lib/client-types/worklog-snapshot.d.ts +33 -0
- package/lib/client.js +5463 -0
- package/lib/config.d.ts +56 -0
- package/lib/config.js +115 -0
- package/lib/cron.d.ts +9 -0
- package/lib/cron.js +127 -0
- package/lib/domain.d.ts +819 -0
- package/lib/domain.js +662 -0
- package/lib/frame-admission.d.ts +6 -0
- package/lib/frame-admission.js +39 -0
- package/lib/frame-reference.d.ts +5 -0
- package/lib/frame-reference.js +12 -0
- package/lib/home-archive.d.ts +17 -0
- package/lib/home-archive.js +177 -0
- package/lib/home-directory.d.ts +6 -0
- package/lib/home-directory.js +38 -0
- package/lib/home-space.d.ts +50 -0
- package/lib/home-space.js +120 -0
- package/lib/home-store.d.ts +126 -0
- package/lib/home-store.js +837 -0
- package/lib/host.d.ts +22 -0
- package/lib/host.js +15 -0
- package/lib/human-inbox-transport.d.ts +23 -0
- package/lib/human-inbox-transport.js +105 -0
- package/lib/human-notification-runner.d.ts +83 -0
- package/lib/human-notification-runner.js +138 -0
- package/lib/human-notification-webhook.d.ts +18 -0
- package/lib/human-notification-webhook.js +102 -0
- package/lib/human-turn-completion.d.ts +61 -0
- package/lib/human-turn-completion.js +157 -0
- package/lib/inbox-return-notifier.d.ts +46 -0
- package/lib/inbox-return-notifier.js +279 -0
- package/lib/inbox-stalled-escalation-runner.d.ts +31 -0
- package/lib/inbox-stalled-escalation-runner.js +68 -0
- package/lib/inbox-stalled-topic.d.ts +16 -0
- package/lib/inbox-stalled-topic.js +44 -0
- package/lib/inbox-wake-policy.d.ts +19 -0
- package/lib/inbox-wake-policy.js +28 -0
- package/lib/inbox-wake-runner.d.ts +45 -0
- package/lib/inbox-wake-runner.js +481 -0
- package/lib/index.d.ts +29 -0
- package/lib/index.js +480 -0
- package/lib/known-format.d.ts +3 -0
- package/lib/known-format.js +8 -0
- package/lib/learning-scheduler.d.ts +37 -0
- package/lib/learning-scheduler.js +182 -0
- package/lib/learning-session-runner.d.ts +50 -0
- package/lib/learning-session-runner.js +435 -0
- package/lib/learning-trigger.d.ts +18 -0
- package/lib/learning-trigger.js +92 -0
- package/lib/learning-usage.d.ts +18 -0
- package/lib/learning-usage.js +49 -0
- package/lib/ledger.d.ts +191 -0
- package/lib/ledger.js +752 -0
- package/lib/local-human-host.d.ts +11 -0
- package/lib/local-human-host.js +191 -0
- package/lib/local-human-token.d.ts +9 -0
- package/lib/local-human-token.js +32 -0
- package/lib/local-owner.d.ts +8 -0
- package/lib/local-owner.js +26 -0
- package/lib/message-source.d.ts +10 -0
- package/lib/message-source.js +2 -0
- package/lib/organization-location.d.ts +20 -0
- package/lib/organization-location.js +80 -0
- package/lib/organization-workspace.d.ts +22 -0
- package/lib/organization-workspace.js +32 -0
- package/lib/project-ledger.d.ts +183 -0
- package/lib/project-ledger.js +189 -0
- package/lib/project-review-transport.d.ts +23 -0
- package/lib/project-review-transport.js +155 -0
- package/lib/project-seat-context.d.ts +18 -0
- package/lib/project-seat-context.js +34 -0
- package/lib/proposal-review-transport.d.ts +26 -0
- package/lib/proposal-review-transport.js +104 -0
- package/lib/route-guard.d.ts +31 -0
- package/lib/route-guard.js +80 -0
- package/lib/safe-file.d.ts +24 -0
- package/lib/safe-file.js +93 -0
- package/lib/sample-organization.d.ts +10 -0
- package/lib/sample-organization.js +46 -0
- package/lib/service.d.ts +597 -0
- package/lib/service.js +4076 -0
- package/lib/session-surface.d.ts +11 -0
- package/lib/session-surface.js +109 -0
- package/lib/shared-knowledge-review-transport.d.ts +28 -0
- package/lib/shared-knowledge-review-transport.js +85 -0
- package/lib/shared-knowledge.d.ts +117 -0
- package/lib/shared-knowledge.js +240 -0
- package/lib/tools.d.ts +7 -0
- package/lib/tools.js +955 -0
- package/lib/ui-contract.d.ts +277 -0
- package/lib/ui-contract.js +12 -0
- package/lib/ui-host.d.ts +24 -0
- package/lib/ui-host.js +471 -0
- package/lib/untrusted-text.d.ts +16 -0
- package/lib/untrusted-text.js +50 -0
- package/lib/work-ledger.d.ts +109 -0
- package/lib/work-ledger.js +107 -0
- package/lib/work-output-eval.d.ts +16 -0
- package/lib/work-output-eval.js +58 -0
- package/lib/work-runner.d.ts +47 -0
- package/lib/work-runner.js +352 -0
- package/lib/worklog-ledger.d.ts +89 -0
- package/lib/worklog-ledger.js +91 -0
- package/lib/worklog-snapshot.d.ts +34 -0
- package/lib/worklog-snapshot.js +100 -0
- package/lib/writer-guard.d.ts +11 -0
- package/lib/writer-guard.js +207 -0
- package/package.json +172 -4
package/lib/tools.js
ADDED
|
@@ -0,0 +1,955 @@
|
|
|
1
|
+
import { defineTool } from '@deepseek-ai/dsh-tools';
|
|
2
|
+
const JSON_OUTPUT = {
|
|
3
|
+
schema: { type: 'json' },
|
|
4
|
+
render: (_args, value) => [{
|
|
5
|
+
type: 'text',
|
|
6
|
+
// Compact JSON: indentation costs context on small local models and adds no information.
|
|
7
|
+
text: JSON.stringify(value),
|
|
8
|
+
}],
|
|
9
|
+
};
|
|
10
|
+
const TAGS = {
|
|
11
|
+
type: 'array',
|
|
12
|
+
description: 'Optional short retrieval tags.',
|
|
13
|
+
items: { type: 'string' },
|
|
14
|
+
};
|
|
15
|
+
export function registerTools(ctx, service, workRunner, learningRunner, onInboxSent) {
|
|
16
|
+
ctx.tools.register(defineTool({
|
|
17
|
+
name: 'bizagent_home_status',
|
|
18
|
+
description: 'Inspect the current session\'s immutable Agent Home binding, revision, memory counts, and proposal queue.',
|
|
19
|
+
parameters: {},
|
|
20
|
+
output: JSON_OUTPUT,
|
|
21
|
+
isConcurrencySafe: () => true,
|
|
22
|
+
execute: async (_args, exec) => jsonResult(service.homeStatus(requireAgent(exec.agent))),
|
|
23
|
+
}));
|
|
24
|
+
ctx.tools.register(defineTool({
|
|
25
|
+
name: 'bizagent_episodes',
|
|
26
|
+
description: 'List DSH Sessions bound to the current Agent Home, newest first. Use a returned session id to read one episode.',
|
|
27
|
+
parameters: {
|
|
28
|
+
before_session_id: { type: 'string', description: 'Pagination cursor returned as nextBeforeSessionId.' },
|
|
29
|
+
limit: { type: 'integer', description: 'Maximum sessions, from 1 to 100. Defaults to 20.' },
|
|
30
|
+
},
|
|
31
|
+
output: JSON_OUTPUT,
|
|
32
|
+
isConcurrencySafe: () => true,
|
|
33
|
+
execute: async (args, exec) => jsonResult(service.listEpisodes(requireAgent(exec.agent), {
|
|
34
|
+
...(args.before_session_id !== undefined ? { beforeSessionId: args.before_session_id } : {}),
|
|
35
|
+
...(args.limit !== undefined ? { limit: args.limit } : {}),
|
|
36
|
+
})),
|
|
37
|
+
}));
|
|
38
|
+
ctx.tools.register(defineTool({
|
|
39
|
+
name: 'bizagent_episode_read',
|
|
40
|
+
description: 'Read a bounded page of raw DSH events from a Session bound to the current Agent Home. Events are evidence, not automatically validated learning.',
|
|
41
|
+
parameters: {
|
|
42
|
+
session_id: { type: 'string', required: true, description: 'Session id returned by bizagent_episodes.' },
|
|
43
|
+
after_seq: { type: 'integer', description: 'Read events after this sequence. Use nextAfterSeq to continue.' },
|
|
44
|
+
limit: { type: 'integer', description: 'Maximum events, from 1 to 24. Defaults to 24.' },
|
|
45
|
+
},
|
|
46
|
+
output: JSON_OUTPUT,
|
|
47
|
+
isConcurrencySafe: () => true,
|
|
48
|
+
execute: async (args, exec) => jsonResult(service.readEpisode(requireAgent(exec.agent), {
|
|
49
|
+
sessionId: args.session_id,
|
|
50
|
+
...(args.after_seq !== undefined ? { afterSeq: args.after_seq } : {}),
|
|
51
|
+
...(args.limit !== undefined ? { limit: args.limit } : {}),
|
|
52
|
+
})),
|
|
53
|
+
}));
|
|
54
|
+
ctx.tools.register(defineTool({
|
|
55
|
+
name: 'bizagent_worklog_record',
|
|
56
|
+
description: 'Save an immutable revision of this Session\'s work summary, backed by its DSH event fingerprint and optional retained Workspace file snapshots. This is work history, not validated Memory.',
|
|
57
|
+
parameters: {
|
|
58
|
+
description: { type: 'string', required: true, description: 'Short searchable summary, up to 240 characters.' },
|
|
59
|
+
body: { type: 'string', required: true, description: 'Outcome, decisions, and useful context, up to 16000 characters.' },
|
|
60
|
+
status: { type: 'string', required: true, enum: ['ongoing', 'completed', 'blocked', 'failed'] },
|
|
61
|
+
idempotency_key: { type: 'string', required: true, description: 'Stable key for this exact revision. Use a new key when revising.' },
|
|
62
|
+
files: { type: 'array', items: { type: 'string' }, description: 'Up to 10 canonical paths relative to this Session Workspace; each file must be at most 8 MiB and its bytes are retained in the Home archive.' },
|
|
63
|
+
project_id: { type: 'string', description: 'Optional visible Project id.' },
|
|
64
|
+
work_id: { type: 'string', description: 'Optional formal Work id owned by this exact Session.' },
|
|
65
|
+
},
|
|
66
|
+
output: JSON_OUTPUT,
|
|
67
|
+
execute: async (args, exec) => jsonResult(service.recordWorklog(requireAgent(exec.agent), {
|
|
68
|
+
description: args.description, body: args.body, status: args.status,
|
|
69
|
+
idempotencyKey: args.idempotency_key,
|
|
70
|
+
...(args.files !== undefined ? { files: args.files } : {}),
|
|
71
|
+
...(args.project_id !== undefined ? { projectId: args.project_id } : {}),
|
|
72
|
+
...(args.work_id !== undefined ? { workId: args.work_id } : {}),
|
|
73
|
+
})),
|
|
74
|
+
}));
|
|
75
|
+
ctx.tools.register(defineTool({
|
|
76
|
+
name: 'bizagent_worklogs',
|
|
77
|
+
description: 'Search the latest Worklog revision per Session in the current Home. Returns short descriptions; read a matching Worklog for its body and source status.',
|
|
78
|
+
parameters: {
|
|
79
|
+
query: { type: 'string', description: 'Case-insensitive substring across summary, body, links, and file paths.' },
|
|
80
|
+
status: { type: 'string', enum: ['ongoing', 'completed', 'blocked', 'failed'] },
|
|
81
|
+
before_session_id: { type: 'string', description: 'Pagination cursor returned as nextBeforeSessionId.' },
|
|
82
|
+
limit: { type: 'integer', description: 'Maximum results, from 1 to 100. Defaults to 20.' },
|
|
83
|
+
},
|
|
84
|
+
output: JSON_OUTPUT,
|
|
85
|
+
isConcurrencySafe: () => true,
|
|
86
|
+
execute: async (args, exec) => jsonResult(service.searchWorklogs(requireAgent(exec.agent), {
|
|
87
|
+
...(args.query !== undefined ? { query: args.query } : {}),
|
|
88
|
+
...(args.status !== undefined ? { status: args.status } : {}),
|
|
89
|
+
...(args.before_session_id !== undefined ? { beforeSessionId: args.before_session_id } : {}),
|
|
90
|
+
...(args.limit !== undefined ? { limit: args.limit } : {}),
|
|
91
|
+
})),
|
|
92
|
+
}));
|
|
93
|
+
ctx.tools.register(defineTool({
|
|
94
|
+
name: 'bizagent_worklog_read',
|
|
95
|
+
description: 'Read one Worklog revision in the current Home, with its full body, prior revision index, Session evidence status, and current and retained file status.',
|
|
96
|
+
parameters: {
|
|
97
|
+
session_id: { type: 'string', required: true, description: 'Session id from bizagent_worklogs or bizagent_episodes.' },
|
|
98
|
+
revision: { type: 'integer', description: 'Specific positive revision number; defaults to the latest.' },
|
|
99
|
+
},
|
|
100
|
+
output: JSON_OUTPUT,
|
|
101
|
+
isConcurrencySafe: () => true,
|
|
102
|
+
execute: async (args, exec) => jsonResult(service.readWorklog(requireAgent(exec.agent), {
|
|
103
|
+
sessionId: args.session_id,
|
|
104
|
+
...(args.revision !== undefined ? { revision: args.revision } : {}),
|
|
105
|
+
})),
|
|
106
|
+
}));
|
|
107
|
+
ctx.tools.register(defineTool({
|
|
108
|
+
name: 'bizagent_worklog_file_read',
|
|
109
|
+
description: 'Read a bounded byte range from a file snapshot retained by one Worklog revision. Returns base64 bytes even if the Workspace file later changed or disappeared.',
|
|
110
|
+
parameters: {
|
|
111
|
+
session_id: { type: 'string', required: true, description: 'Session id that owns the Worklog.' },
|
|
112
|
+
revision: { type: 'integer', description: 'Specific positive Worklog revision; defaults to the latest.' },
|
|
113
|
+
path: { type: 'string', required: true, description: 'Canonical relative file path listed by bizagent_worklog_read.' },
|
|
114
|
+
offset: { type: 'integer', description: 'Byte offset, from 0 to the snapshot size. Defaults to 0.' },
|
|
115
|
+
limit: { type: 'integer', description: 'Maximum bytes, from 1 to 65536. Defaults to 8192.' },
|
|
116
|
+
},
|
|
117
|
+
output: JSON_OUTPUT,
|
|
118
|
+
isConcurrencySafe: () => true,
|
|
119
|
+
execute: async (args, exec) => jsonResult(service.readWorklogFile(requireAgent(exec.agent), {
|
|
120
|
+
sessionId: args.session_id, path: args.path,
|
|
121
|
+
...(args.revision !== undefined ? { revision: args.revision } : {}),
|
|
122
|
+
...(args.offset !== undefined ? { offset: args.offset } : {}),
|
|
123
|
+
...(args.limit !== undefined ? { limit: args.limit } : {}),
|
|
124
|
+
})),
|
|
125
|
+
}));
|
|
126
|
+
ctx.tools.register(defineTool({
|
|
127
|
+
name: 'bizagent_learning_materials',
|
|
128
|
+
description: 'Scan earlier Sessions and authored Worklog revisions bound to this Home for new or changed learning material. Reading does not mark it reviewed; each result freezes one source fingerprint.',
|
|
129
|
+
parameters: {
|
|
130
|
+
before_session_id: { type: 'string', description: 'Pagination cursor returned as nextBeforeSessionId.' },
|
|
131
|
+
limit: { type: 'integer', description: 'Maximum Sessions to inspect, from 1 to 20. Defaults to 10.' },
|
|
132
|
+
},
|
|
133
|
+
output: JSON_OUTPUT,
|
|
134
|
+
execute: async (args, exec) => jsonResult(service.scanLearningMaterials(requireAgent(exec.agent), {
|
|
135
|
+
...(args.before_session_id !== undefined ? { beforeSessionId: args.before_session_id } : {}),
|
|
136
|
+
...(args.limit !== undefined ? { limit: args.limit } : {}),
|
|
137
|
+
})),
|
|
138
|
+
}));
|
|
139
|
+
ctx.tools.register(defineTool({
|
|
140
|
+
name: 'bizagent_learning_review',
|
|
141
|
+
description: 'Record that one frozen, current-Home learning material was deliberately reviewed. This does not publish memory. A changed Session will appear as new material on the next scan.',
|
|
142
|
+
parameters: {
|
|
143
|
+
material_id: { type: 'string', required: true, description: 'Material id returned by bizagent_learning_materials.' },
|
|
144
|
+
summary: { type: 'string', required: true, description: 'What was learned, retained, or deliberately left unchanged, with a concrete reason.' },
|
|
145
|
+
},
|
|
146
|
+
output: JSON_OUTPUT,
|
|
147
|
+
execute: async (args, exec) => jsonResult(service.reviewLearningMaterial(requireAgent(exec.agent), {
|
|
148
|
+
materialId: args.material_id,
|
|
149
|
+
summary: args.summary,
|
|
150
|
+
})),
|
|
151
|
+
}));
|
|
152
|
+
ctx.tools.register(defineTool({
|
|
153
|
+
name: 'bizagent_learning_batch_start',
|
|
154
|
+
description: 'Freeze up to eight unreviewed Session or authored Worklog materials for a dedicated current-Home learning review. Only one batch may be open per Home. This Session is excluded from later learning scans.',
|
|
155
|
+
parameters: {}, output: JSON_OUTPUT,
|
|
156
|
+
execute: async (_args, exec) => jsonResult(service.startLearningBatch(requireAgent(exec.agent), String(exec.callId))),
|
|
157
|
+
}));
|
|
158
|
+
ctx.tools.register(defineTool({
|
|
159
|
+
name: 'bizagent_learning_batch_status',
|
|
160
|
+
description: 'Read durable progress of a current-Home learning batch after a restart or lost response.',
|
|
161
|
+
parameters: { run_id: { type: 'string', required: true } }, output: JSON_OUTPUT,
|
|
162
|
+
isConcurrencySafe: () => true,
|
|
163
|
+
execute: async (args, exec) => jsonResult(service.learningBatchStatus(requireAgent(exec.agent), args.run_id)),
|
|
164
|
+
}));
|
|
165
|
+
ctx.tools.register(defineTool({
|
|
166
|
+
name: 'bizagent_learning_batch_change_read',
|
|
167
|
+
description: 'Read retained before or after bytes for one actual managed Home file change recorded when a learning batch finished. Changes show concurrent writes too; they do not establish which Session caused them.',
|
|
168
|
+
parameters: {
|
|
169
|
+
run_id: { type: 'string', required: true },
|
|
170
|
+
path: { type: 'string', required: true, description: 'Exact path from run.libraryChanges.' },
|
|
171
|
+
side: { type: 'string', required: true, enum: ['before', 'after'] },
|
|
172
|
+
offset: { type: 'integer', description: 'Byte offset in the retained snapshot, default 0.' },
|
|
173
|
+
limit: { type: 'integer', description: 'Bytes to read, default 8192, maximum 65536.' },
|
|
174
|
+
}, output: JSON_OUTPUT,
|
|
175
|
+
isConcurrencySafe: () => true,
|
|
176
|
+
execute: async (args, exec) => jsonResult(service.readLearningBatchChange(requireAgent(exec.agent), {
|
|
177
|
+
runId: args.run_id, path: args.path, side: args.side,
|
|
178
|
+
...(args.offset !== undefined ? { offset: args.offset } : {}),
|
|
179
|
+
...(args.limit !== undefined ? { limit: args.limit } : {}),
|
|
180
|
+
})),
|
|
181
|
+
}));
|
|
182
|
+
ctx.tools.register(defineTool({
|
|
183
|
+
name: 'bizagent_learning_batch_settle',
|
|
184
|
+
description: 'Review one frozen material. Session candidates cite bounded event ranges; Worklog candidates cite the exact frozen Worklog revision and omit event sequence fields. All remain inactive until published. Empty candidates records a reasoned no-change review.',
|
|
185
|
+
parameters: {
|
|
186
|
+
run_id: { type: 'string', required: true },
|
|
187
|
+
material_id: { type: 'string', required: true },
|
|
188
|
+
summary: { type: 'string', required: true },
|
|
189
|
+
candidates: { type: 'array', items: {
|
|
190
|
+
type: 'object', additionalProperties: false, properties: {
|
|
191
|
+
kind: { type: 'string', required: true, enum: ['memory', 'insight', 'knowledge', 'method'] },
|
|
192
|
+
description: { type: 'string', required: true },
|
|
193
|
+
body: { type: 'string', required: true },
|
|
194
|
+
from_seq: { type: 'integer', description: 'Required for Session event material; omit for Worklog material.' },
|
|
195
|
+
to_seq: { type: 'integer', description: 'Required for Session event material; omit for Worklog material.' },
|
|
196
|
+
tags: TAGS,
|
|
197
|
+
},
|
|
198
|
+
} },
|
|
199
|
+
}, output: JSON_OUTPUT,
|
|
200
|
+
execute: async (args, exec) => jsonResult(service.settleLearningBatchMaterial(requireAgent(exec.agent), {
|
|
201
|
+
runId: args.run_id, materialId: args.material_id, summary: args.summary,
|
|
202
|
+
...(args.candidates !== undefined ? { candidates: args.candidates.map(item => ({
|
|
203
|
+
kind: item.kind, description: item.description, body: item.body,
|
|
204
|
+
...(item.from_seq !== undefined ? { fromSeq: item.from_seq } : {}),
|
|
205
|
+
...(item.to_seq !== undefined ? { toSeq: item.to_seq } : {}),
|
|
206
|
+
...(item.tags !== undefined ? { tags: item.tags } : {}),
|
|
207
|
+
})) } : {}),
|
|
208
|
+
})),
|
|
209
|
+
}));
|
|
210
|
+
ctx.tools.register(defineTool({
|
|
211
|
+
name: 'bizagent_learning_batch_finish',
|
|
212
|
+
description: 'Complete a fully reviewed batch in its reviewer Session, or abandon an interrupted batch from the same Home with a reason. Unreviewed materials remain available after abandonment.',
|
|
213
|
+
parameters: {
|
|
214
|
+
run_id: { type: 'string', required: true },
|
|
215
|
+
action: { type: 'string', required: true, enum: ['complete', 'abandon'] },
|
|
216
|
+
summary: { type: 'string', required: true },
|
|
217
|
+
}, output: JSON_OUTPUT,
|
|
218
|
+
execute: async (args, exec) => jsonResult(service.finishLearningBatch(requireAgent(exec.agent), {
|
|
219
|
+
runId: args.run_id, action: args.action, summary: args.summary,
|
|
220
|
+
})),
|
|
221
|
+
}));
|
|
222
|
+
ctx.tools.register(defineTool({
|
|
223
|
+
name: 'bizagent_learning_launch',
|
|
224
|
+
description: 'Explicitly reserve and start one dedicated learning Session in the current Home mapped Workspace. A lost factory result is held for inspection; this tool never blindly creates another Session.',
|
|
225
|
+
parameters: {
|
|
226
|
+
idempotency_key: { type: 'string', required: true, description: 'Stable key for this exact launch.' },
|
|
227
|
+
model: { type: 'string', description: 'Optional model for the dedicated Session.' },
|
|
228
|
+
}, output: JSON_OUTPUT,
|
|
229
|
+
execute: async (args, exec) => jsonResult(learningRunner.request(requireAgent(exec.agent), args.idempotency_key, args.model)),
|
|
230
|
+
}));
|
|
231
|
+
ctx.tools.register(defineTool({
|
|
232
|
+
name: 'bizagent_learning_launch_read',
|
|
233
|
+
description: 'Read current-Home learning launch, batch, and reported worker Session token usage. Missing usage stays unavailable; USD cost is unknown.',
|
|
234
|
+
parameters: { launch_id: { type: 'string', required: true } }, output: JSON_OUTPUT,
|
|
235
|
+
isConcurrencySafe: () => true,
|
|
236
|
+
execute: async (args, exec) => jsonResult(learningRunner.read(requireAgent(exec.agent), args.launch_id)),
|
|
237
|
+
}));
|
|
238
|
+
ctx.tools.register(defineTool({
|
|
239
|
+
name: 'bizagent_learning_launch_abandon',
|
|
240
|
+
description: 'After inspection, abandon an uncertain learning launch only when its worker is not live and it has no open batch. Requires a concrete reason.',
|
|
241
|
+
parameters: {
|
|
242
|
+
launch_id: { type: 'string', required: true },
|
|
243
|
+
reason: { type: 'string', required: true },
|
|
244
|
+
}, output: JSON_OUTPUT,
|
|
245
|
+
execute: async (args, exec) => jsonResult(learningRunner.abandon(requireAgent(exec.agent), args.launch_id, args.reason)),
|
|
246
|
+
}));
|
|
247
|
+
ctx.tools.register(defineTool({
|
|
248
|
+
name: 'bizagent_agent_search',
|
|
249
|
+
description: 'Find active Home addresses by name or address in this organization. Returns the current Personal Home and shared Business, Role, and Capability Homes; use the canonical address for Inbox, Work, or Project.',
|
|
250
|
+
parameters: {
|
|
251
|
+
query: { type: 'string', description: 'Optional case-insensitive Home name, type, or address fragment.' },
|
|
252
|
+
limit: { type: 'integer', description: 'Maximum results, from 1 to 50. Defaults to 20.' },
|
|
253
|
+
},
|
|
254
|
+
output: JSON_OUTPUT,
|
|
255
|
+
isConcurrencySafe: () => true,
|
|
256
|
+
execute: async (args, exec) => jsonResult(service.searchHomes(requireAgent(exec.agent), {
|
|
257
|
+
...(args.query !== undefined ? { query: args.query } : {}),
|
|
258
|
+
...(args.limit !== undefined ? { limit: args.limit } : {}),
|
|
259
|
+
})),
|
|
260
|
+
}));
|
|
261
|
+
ctx.tools.register(defineTool({
|
|
262
|
+
name: 'bizagent_frame_status',
|
|
263
|
+
description: 'Inspect read-only Agent Frames active in this Session, including whether context needs refreshing after DSH compaction. The primary Home and tool authority remain unchanged.',
|
|
264
|
+
parameters: {},
|
|
265
|
+
output: JSON_OUTPUT,
|
|
266
|
+
isConcurrencySafe: () => true,
|
|
267
|
+
execute: async (_args, exec) => jsonResult(service.frameStatus(requireAgent(exec.agent))),
|
|
268
|
+
}));
|
|
269
|
+
ctx.tools.register(defineTool({
|
|
270
|
+
name: 'bizagent_frame_open',
|
|
271
|
+
description: 'Explicitly attach a shared Business, Role, or Capability Home as read-only context in the current Session. Every result carries mode-specific participation guidance; opened, changed, or refreshed Frames also return bounded Identity and active asset index. Does not create an independent Agent or grant write access.',
|
|
272
|
+
parameters: {
|
|
273
|
+
address: { type: 'string', required: true, description: 'Canonical target Home address or a unique display name from bizagent_agent_search.' },
|
|
274
|
+
mode: { type: 'string', enum: ['lead', 'contribute', 'reference'], description: 'lead guides domain reasoning, contribute adds a specialist perspective, reference supplies attributed material; defaults to lead. This does not change tool authority.' },
|
|
275
|
+
refresh: { type: 'boolean', description: 'Force a new context epoch and return the full bounded Frame context. A successful DSH compaction triggers this automatically on the next open.' },
|
|
276
|
+
},
|
|
277
|
+
output: JSON_OUTPUT,
|
|
278
|
+
execute: async (args, exec) => jsonResult(service.openFrame(requireAgent(exec.agent), {
|
|
279
|
+
address: args.address,
|
|
280
|
+
...(args.mode !== undefined ? { mode: args.mode } : {}),
|
|
281
|
+
...(args.refresh !== undefined ? { refresh: args.refresh } : {}),
|
|
282
|
+
})),
|
|
283
|
+
}));
|
|
284
|
+
ctx.tools.register(defineTool({
|
|
285
|
+
name: 'bizagent_frame_search',
|
|
286
|
+
description: 'Search active assets of an explicitly opened read-only Agent Frame. Uses the most recently opened Frame when address is omitted.',
|
|
287
|
+
parameters: {
|
|
288
|
+
address: { type: 'string', description: 'An open Frame address; defaults to the current focus.' },
|
|
289
|
+
query: { type: 'string', description: 'Optional case-insensitive text query.' },
|
|
290
|
+
kind: { type: 'string', enum: ['memory', 'insight', 'knowledge', 'method', 'identity'] },
|
|
291
|
+
limit: { type: 'integer', description: 'Maximum results, from 1 to 100. Defaults to 20.' },
|
|
292
|
+
},
|
|
293
|
+
output: JSON_OUTPUT,
|
|
294
|
+
isConcurrencySafe: () => true,
|
|
295
|
+
execute: async (args, exec) => jsonResult(service.searchFrame(requireAgent(exec.agent), {
|
|
296
|
+
...(args.address !== undefined ? { address: args.address } : {}),
|
|
297
|
+
...(args.query !== undefined ? { query: args.query } : {}),
|
|
298
|
+
...(args.kind !== undefined ? { kind: args.kind } : {}),
|
|
299
|
+
...(args.limit !== undefined ? { limit: args.limit } : {}),
|
|
300
|
+
})),
|
|
301
|
+
}));
|
|
302
|
+
ctx.tools.register(defineTool({
|
|
303
|
+
name: 'bizagent_frame_read',
|
|
304
|
+
description: 'Read one active asset body from an explicitly opened Agent Frame and record a retrieval receipt; no cross-Home write permission is granted.',
|
|
305
|
+
parameters: {
|
|
306
|
+
asset_id: { type: 'string', required: true },
|
|
307
|
+
address: { type: 'string', description: 'An open Frame address; defaults to the current focus.' },
|
|
308
|
+
},
|
|
309
|
+
output: JSON_OUTPUT,
|
|
310
|
+
isConcurrencySafe: () => true,
|
|
311
|
+
execute: async (args, exec) => jsonResult(service.readFrame(requireAgent(exec.agent), String(exec.callId), {
|
|
312
|
+
assetId: args.asset_id,
|
|
313
|
+
...(args.address !== undefined ? { address: args.address } : {}),
|
|
314
|
+
})),
|
|
315
|
+
}));
|
|
316
|
+
ctx.tools.register(defineTool({
|
|
317
|
+
name: 'bizagent_frame_close',
|
|
318
|
+
description: 'Close one read-only Agent Frame; defaults to the current focus. Earlier tool results remain in the DSH transcript.',
|
|
319
|
+
parameters: {
|
|
320
|
+
address: { type: 'string', description: 'An open Frame address; defaults to the current focus.' },
|
|
321
|
+
},
|
|
322
|
+
output: JSON_OUTPUT,
|
|
323
|
+
execute: async (args, exec) => jsonResult(service.closeFrame(requireAgent(exec.agent), args.address)),
|
|
324
|
+
}));
|
|
325
|
+
ctx.tools.register(defineTool({
|
|
326
|
+
name: 'bizagent_inbox_send',
|
|
327
|
+
description: 'Send immutable Inbox mail to Agent Homes or users. In a Project, project_id resolves joined Homes to Seat addresses; replies inherit the parent Project and preserve historical sender addresses. A conclusion requires an existing Workspace file. An escalation requires a primary user:<id>, due, and human_action. Delivered means stored in the recipient inbox; it does not prove a push, read, or completed work.',
|
|
328
|
+
parameters: {
|
|
329
|
+
to: { type: 'array', required: true, items: { type: 'string' }, description: 'One to eight primary Home or user:<id> addresses.' },
|
|
330
|
+
cc: { type: 'array', items: { type: 'string' }, description: 'Optional copy recipients; eight distinct recipients maximum overall.' },
|
|
331
|
+
subject: { type: 'string', required: true },
|
|
332
|
+
body: { type: 'string', required: true, description: 'Markdown message, up to 16000 characters.' },
|
|
333
|
+
kind: { type: 'string', enum: ['ordinary', 'conclusion', 'escalation'], description: 'Defaults to ordinary. Conclusion or escalation closes the topic without waking an Agent.' },
|
|
334
|
+
priority: { type: 'string', enum: ['normal', 'urgent'], description: 'Urgent messages wake an eligible primary recipient immediately; normal messages follow that Home\'s Inbox policy.' },
|
|
335
|
+
due: { type: 'string', description: 'Optional ISO date-time for a one-time reminder if a primary recipient has not handled the letter.' },
|
|
336
|
+
context_refs: { type: 'array', items: { type: 'string' }, description: 'Up to 16 source references. A conclusion requires one existing relative file path inside the bound Workspace.' },
|
|
337
|
+
human_action: {
|
|
338
|
+
type: 'object', additionalProperties: false,
|
|
339
|
+
description: 'Required for escalation to a person: the requested decision and reason.',
|
|
340
|
+
properties: {
|
|
341
|
+
request: { type: 'string', required: true },
|
|
342
|
+
reason: { type: 'string', required: true },
|
|
343
|
+
recommendation: { type: 'string' },
|
|
344
|
+
href: { type: 'string', description: 'Optional application page path.' },
|
|
345
|
+
label: { type: 'string' },
|
|
346
|
+
},
|
|
347
|
+
},
|
|
348
|
+
reply_to: { type: 'string', description: 'Visible thread message id to reply to.' },
|
|
349
|
+
project_id: { type: 'string', description: 'Optional Project context. Requires lead or active Seat membership; joined recipients route to their Seat addresses.' },
|
|
350
|
+
idempotency_key: { type: 'string', description: 'Stable key for safe retry; defaults to the DSH tool call id.' },
|
|
351
|
+
},
|
|
352
|
+
output: JSON_OUTPUT,
|
|
353
|
+
execute: async (args, exec) => {
|
|
354
|
+
const result = await service.sendInboxMessage(requireAgent(exec.agent), String(exec.callId), {
|
|
355
|
+
to: args.to,
|
|
356
|
+
...(args.cc !== undefined ? { cc: args.cc } : {}),
|
|
357
|
+
subject: args.subject, body: args.body,
|
|
358
|
+
...(args.kind !== undefined ? { kind: args.kind } : {}),
|
|
359
|
+
...(args.priority !== undefined ? { priority: args.priority } : {}),
|
|
360
|
+
...(args.due !== undefined ? { due: args.due } : {}),
|
|
361
|
+
...(args.context_refs !== undefined ? { contextRefs: args.context_refs } : {}),
|
|
362
|
+
...(args.human_action !== undefined ? { humanAction: args.human_action } : {}),
|
|
363
|
+
...(args.reply_to !== undefined ? { replyTo: args.reply_to } : {}),
|
|
364
|
+
...(args.project_id !== undefined ? { projectId: args.project_id } : {}),
|
|
365
|
+
...(args.idempotency_key !== undefined ? { idempotencyKey: args.idempotency_key } : {}),
|
|
366
|
+
});
|
|
367
|
+
const message = result.message;
|
|
368
|
+
if (message.kind === 'ordinary')
|
|
369
|
+
onInboxSent?.(message);
|
|
370
|
+
return jsonResult(Promise.resolve(result));
|
|
371
|
+
},
|
|
372
|
+
}));
|
|
373
|
+
ctx.tools.register(defineTool({
|
|
374
|
+
name: 'bizagent_inbox',
|
|
375
|
+
description: 'List incoming, outgoing, or both message headers for the current Home. Incoming defaults to all delivered messages; pending_only selects unhandled messages.',
|
|
376
|
+
parameters: {
|
|
377
|
+
direction: { type: 'string', enum: ['incoming', 'outgoing', 'both'] },
|
|
378
|
+
pending_only: { type: 'boolean' },
|
|
379
|
+
before_message_id: { type: 'string' },
|
|
380
|
+
limit: { type: 'integer', description: 'Maximum 100 headers; defaults to 20.' },
|
|
381
|
+
},
|
|
382
|
+
output: JSON_OUTPUT,
|
|
383
|
+
isConcurrencySafe: () => true,
|
|
384
|
+
execute: async (args, exec) => jsonResult(service.listInbox(requireAgent(exec.agent), {
|
|
385
|
+
...(args.direction !== undefined ? { direction: args.direction } : {}),
|
|
386
|
+
...(args.pending_only !== undefined ? { pendingOnly: args.pending_only } : {}),
|
|
387
|
+
...(args.before_message_id !== undefined ? { beforeMessageId: args.before_message_id } : {}),
|
|
388
|
+
...(args.limit !== undefined ? { limit: args.limit } : {}),
|
|
389
|
+
})),
|
|
390
|
+
}));
|
|
391
|
+
ctx.tools.register(defineTool({
|
|
392
|
+
name: 'bizagent_inbox_read',
|
|
393
|
+
description: 'Read one Inbox message visible to the current Home. Reading does not mark it handled.',
|
|
394
|
+
parameters: { message_id: { type: 'string', required: true } },
|
|
395
|
+
output: JSON_OUTPUT,
|
|
396
|
+
isConcurrencySafe: () => true,
|
|
397
|
+
execute: async (args, exec) => jsonResult(service.readInboxMessage(requireAgent(exec.agent), args.message_id)),
|
|
398
|
+
}));
|
|
399
|
+
ctx.tools.register(defineTool({
|
|
400
|
+
name: 'bizagent_inbox_handle',
|
|
401
|
+
description: 'Mark one delivered message handled in the current Home inbox. This is a mailbox receipt, not a Work result or approval.',
|
|
402
|
+
parameters: { message_id: { type: 'string', required: true } },
|
|
403
|
+
output: JSON_OUTPUT,
|
|
404
|
+
execute: async (args, exec) => jsonResult(service.handleInboxMessage(requireAgent(exec.agent), args.message_id)),
|
|
405
|
+
}));
|
|
406
|
+
ctx.tools.register(defineTool({
|
|
407
|
+
name: 'bizagent_project_create',
|
|
408
|
+
description: 'Create one durable Project owned by the current Home, with a goal and completion standard. Reuse the idempotency key on retry.',
|
|
409
|
+
parameters: {
|
|
410
|
+
title: { type: 'string', required: true },
|
|
411
|
+
goal: { type: 'string', required: true },
|
|
412
|
+
done_when: { type: 'string', required: true, description: 'Concrete completion standard for later review.' },
|
|
413
|
+
idempotency_key: { type: 'string', required: true },
|
|
414
|
+
},
|
|
415
|
+
output: JSON_OUTPUT,
|
|
416
|
+
execute: async (args, exec) => jsonResult(service.createProject(requireAgent(exec.agent), {
|
|
417
|
+
title: args.title, goal: args.goal, doneWhen: args.done_when, idempotencyKey: args.idempotency_key,
|
|
418
|
+
})),
|
|
419
|
+
}));
|
|
420
|
+
ctx.tools.register(defineTool({
|
|
421
|
+
name: 'bizagent_projects',
|
|
422
|
+
description: 'List compact summaries of Projects led by the current Home or visible through an active Project Seat. Read one Project with bizagent_project_read. A Project status is not evidence that DSH agents are currently running.',
|
|
423
|
+
parameters: {
|
|
424
|
+
status: { type: 'string', enum: ['open', 'awaiting_acceptance', 'accepted'] },
|
|
425
|
+
before_project_id: { type: 'string', description: 'Pagination cursor returned as nextBeforeProjectId.' },
|
|
426
|
+
limit: { type: 'integer', description: 'Maximum 100 Projects; defaults to 20.' },
|
|
427
|
+
},
|
|
428
|
+
output: JSON_OUTPUT,
|
|
429
|
+
isConcurrencySafe: () => true,
|
|
430
|
+
execute: async (args, exec) => jsonResult(service.listProjects(requireAgent(exec.agent), {
|
|
431
|
+
...(args.status !== undefined ? { status: args.status } : {}),
|
|
432
|
+
...(args.before_project_id !== undefined ? { beforeProjectId: args.before_project_id } : {}),
|
|
433
|
+
...(args.limit !== undefined ? { limit: args.limit } : {}),
|
|
434
|
+
}).then(result => ({ ...result, projects: result.projects.map(projectSummary) }))),
|
|
435
|
+
}));
|
|
436
|
+
ctx.tools.register(defineTool({
|
|
437
|
+
name: 'bizagent_project_read',
|
|
438
|
+
description: 'As the lead or an active Project Seat Home, read one Project, its versioned submissions and reviews, and summaries of its linked formal Work. Read a Work result with bizagent_work_read.',
|
|
439
|
+
parameters: { project_id: { type: 'string', required: true } },
|
|
440
|
+
output: JSON_OUTPUT,
|
|
441
|
+
isConcurrencySafe: () => true,
|
|
442
|
+
execute: async (args, exec) => jsonResult(service.readProject(requireAgent(exec.agent), args.project_id)
|
|
443
|
+
.then(result => ({ ...result, work: result.work.map(workSummary) }))),
|
|
444
|
+
}));
|
|
445
|
+
ctx.tools.register(defineTool({
|
|
446
|
+
name: 'bizagent_project_turn_join',
|
|
447
|
+
description: 'Bind the current DSH turn to an open Project before doing Project work in an ordinary Home Session. Unrelated later turns remain independent. Repeat in each new Project turn.',
|
|
448
|
+
parameters: { project_id: { type: 'string', required: true } },
|
|
449
|
+
output: JSON_OUTPUT,
|
|
450
|
+
execute: async (args, exec) => jsonResult(service.joinProjectTurn(requireAgent(exec.agent), args.project_id)),
|
|
451
|
+
}));
|
|
452
|
+
ctx.tools.register(defineTool({
|
|
453
|
+
name: 'bizagent_project_invite',
|
|
454
|
+
description: 'As the lead of an open Project, invite an active shared Agent Home to a durable Project Seat with a stated responsibility. The invitation grants Project read access; it does not dispatch or accept Work.',
|
|
455
|
+
parameters: {
|
|
456
|
+
project_id: { type: 'string', required: true },
|
|
457
|
+
home_address: { type: 'string', required: true },
|
|
458
|
+
responsibility: { type: 'string', required: true },
|
|
459
|
+
},
|
|
460
|
+
output: JSON_OUTPUT,
|
|
461
|
+
execute: async (args, exec) => jsonResult(service.inviteProjectSeat(requireAgent(exec.agent), {
|
|
462
|
+
projectId: args.project_id, homeAddress: args.home_address,
|
|
463
|
+
responsibility: args.responsibility,
|
|
464
|
+
})),
|
|
465
|
+
}));
|
|
466
|
+
ctx.tools.register(defineTool({
|
|
467
|
+
name: 'bizagent_project_seat_release',
|
|
468
|
+
description: 'As the Project lead, release a Seat with no unsettled linked formal Work and revoke its Project read access.',
|
|
469
|
+
parameters: {
|
|
470
|
+
project_id: { type: 'string', required: true },
|
|
471
|
+
seat_address: { type: 'string', required: true },
|
|
472
|
+
},
|
|
473
|
+
output: JSON_OUTPUT,
|
|
474
|
+
execute: async (args, exec) => jsonResult(service.releaseProjectSeat(requireAgent(exec.agent), {
|
|
475
|
+
projectId: args.project_id, seatAddress: args.seat_address,
|
|
476
|
+
})),
|
|
477
|
+
}));
|
|
478
|
+
ctx.tools.register(defineTool({
|
|
479
|
+
name: 'bizagent_project_submit',
|
|
480
|
+
description: 'Submit one result claim against the Project completion standard after all linked formal Work is terminal. Reference up to ten Workspace artifacts to retain their exact bytes; without artifacts, a delivered formal Work result is required. This does not prove no DSH run is active.',
|
|
481
|
+
parameters: {
|
|
482
|
+
project_id: { type: 'string', required: true },
|
|
483
|
+
summary: { type: 'string', required: true },
|
|
484
|
+
body: { type: 'string', required: true },
|
|
485
|
+
done_when_assessment: { type: 'string', required: true },
|
|
486
|
+
artifact_refs: { type: 'array', items: { type: 'string' }, description: 'Canonical files under artifacts/ in this Session Workspace; up to 10, each at most 8 MiB.' },
|
|
487
|
+
},
|
|
488
|
+
output: JSON_OUTPUT,
|
|
489
|
+
execute: async (args, exec) => jsonResult(service.submitProject(requireAgent(exec.agent), {
|
|
490
|
+
projectId: args.project_id, summary: args.summary, body: args.body,
|
|
491
|
+
doneWhenAssessment: args.done_when_assessment,
|
|
492
|
+
...(args.artifact_refs !== undefined ? { artifactRefs: args.artifact_refs } : {}),
|
|
493
|
+
})),
|
|
494
|
+
}));
|
|
495
|
+
ctx.tools.register(defineTool({
|
|
496
|
+
name: 'bizagent_project_artifact_read',
|
|
497
|
+
description: 'Read a bounded byte range from an immutable artifact snapshot in one Project result claim. The source Workspace file may have changed or disappeared.',
|
|
498
|
+
parameters: {
|
|
499
|
+
project_id: { type: 'string', required: true },
|
|
500
|
+
claim_id: { type: 'string', required: true },
|
|
501
|
+
path: { type: 'string', required: true, description: 'Artifact path listed in the claim.' },
|
|
502
|
+
offset: { type: 'integer', description: 'Byte offset, defaults to 0.' },
|
|
503
|
+
limit: { type: 'integer', description: 'Maximum bytes, from 1 to 65536. Defaults to 8192.' },
|
|
504
|
+
},
|
|
505
|
+
output: JSON_OUTPUT,
|
|
506
|
+
isConcurrencySafe: () => true,
|
|
507
|
+
execute: async (args, exec) => jsonResult(service.readProjectArtifact(requireAgent(exec.agent), {
|
|
508
|
+
projectId: args.project_id, claimId: args.claim_id, path: args.path,
|
|
509
|
+
...(args.offset !== undefined ? { offset: args.offset } : {}),
|
|
510
|
+
...(args.limit !== undefined ? { limit: args.limit } : {}),
|
|
511
|
+
})),
|
|
512
|
+
}));
|
|
513
|
+
ctx.tools.register(defineTool({
|
|
514
|
+
name: 'bizagent_project_review',
|
|
515
|
+
description: 'As the lead Home, request rework on the exact pending Project claim. Final acceptance requires the authenticated human Project review route.',
|
|
516
|
+
parameters: {
|
|
517
|
+
project_id: { type: 'string', required: true },
|
|
518
|
+
claim_id: { type: 'string', required: true },
|
|
519
|
+
decision: { type: 'string', required: true, enum: ['rework'] },
|
|
520
|
+
reason: { type: 'string', required: true },
|
|
521
|
+
},
|
|
522
|
+
output: JSON_OUTPUT,
|
|
523
|
+
execute: async (args, exec) => jsonResult(service.reviewProject(requireAgent(exec.agent), {
|
|
524
|
+
projectId: args.project_id, claimId: args.claim_id,
|
|
525
|
+
decision: args.decision, reason: args.reason,
|
|
526
|
+
})),
|
|
527
|
+
}));
|
|
528
|
+
ctx.tools.register(defineTool({
|
|
529
|
+
name: 'bizagent_work_dispatch',
|
|
530
|
+
description: 'Create one formal Work responsibility and request notification, then start an independent DSH worker Session in the assignee Home when both Homes have the same owner. Otherwise the Work stays open for the assignee\'s own Sessions. A launch failure is returned separately; the Work remains durable and can be retried with bizagent_work_start.',
|
|
531
|
+
parameters: {
|
|
532
|
+
to_address: { type: 'string', required: true, description: 'Assignee Agent Home address.' },
|
|
533
|
+
goal: { type: 'string', required: true, description: 'What the assignee must achieve, in at most 200 characters; put details in acceptance_criteria.' },
|
|
534
|
+
acceptance_criteria: { type: 'string', required: true, description: 'Concrete completion criteria.' },
|
|
535
|
+
idempotency_key: { type: 'string', required: true, description: 'Stable key for this responsibility; retries must reuse it.' },
|
|
536
|
+
project_id: { type: 'string', description: 'Optional existing open Project led by the requester Home.' },
|
|
537
|
+
},
|
|
538
|
+
output: JSON_OUTPUT,
|
|
539
|
+
execute: async (args, exec) => {
|
|
540
|
+
const agent = requireAgent(exec.agent);
|
|
541
|
+
const result = await service.dispatchWork(agent, {
|
|
542
|
+
toAddress: args.to_address, goal: args.goal, acceptanceCriteria: args.acceptance_criteria,
|
|
543
|
+
idempotencyKey: args.idempotency_key,
|
|
544
|
+
...(args.project_id !== undefined ? { projectId: args.project_id } : {}),
|
|
545
|
+
});
|
|
546
|
+
const work = result.work;
|
|
547
|
+
if (work?.status === 'open' && work.autoStart !== true
|
|
548
|
+
&& service.workAutoStartBlock(work.requester, work.assignee) === 'different-owner') {
|
|
549
|
+
return JSON.parse(JSON.stringify({ ...result, workerLaunch: { status: 'not-started',
|
|
550
|
+
reason: 'different-owner',
|
|
551
|
+
detail: 'The requester and assignee Homes do not have the same owner, so no worker Session was started. '
|
|
552
|
+
+ 'The Work stays open for the assignee to accept from its own Session.' } }));
|
|
553
|
+
}
|
|
554
|
+
if (work?.status !== 'open' || work.autoStart !== true)
|
|
555
|
+
return JSON.parse(JSON.stringify(result));
|
|
556
|
+
try {
|
|
557
|
+
const workerLaunch = await workRunner.start(agent, work.id);
|
|
558
|
+
return JSON.parse(JSON.stringify({ ...result, workerLaunch }));
|
|
559
|
+
}
|
|
560
|
+
catch (error) {
|
|
561
|
+
service.recordRuntimeError(`Work start ${work.id}`, error);
|
|
562
|
+
return JSON.parse(JSON.stringify({ ...result, workerLaunch: {
|
|
563
|
+
status: 'failed', reason: error instanceof Error ? error.message : String(error),
|
|
564
|
+
} }));
|
|
565
|
+
}
|
|
566
|
+
},
|
|
567
|
+
}));
|
|
568
|
+
ctx.tools.register(defineTool({
|
|
569
|
+
name: 'bizagent_work_start',
|
|
570
|
+
description: 'As the requester, create or resume the one reserved DSH worker Session for an existing Work and wake it with the request. Requires the same owner for the requester and assignee Homes. Safe to retry after a launch failure.',
|
|
571
|
+
parameters: { work_id: { type: 'string', required: true } },
|
|
572
|
+
output: JSON_OUTPUT,
|
|
573
|
+
execute: async (args, exec) => jsonResult(workRunner.start(requireAgent(exec.agent), args.work_id)),
|
|
574
|
+
}));
|
|
575
|
+
ctx.tools.register(defineTool({
|
|
576
|
+
name: 'bizagent_work',
|
|
577
|
+
description: 'List compact summaries of formal Work assigned to or requested by the current Home. Read one Work and its result with bizagent_work_read. Work status is separate from Inbox message handling.',
|
|
578
|
+
parameters: {
|
|
579
|
+
direction: { type: 'string', enum: ['assigned', 'requested', 'both'] },
|
|
580
|
+
status: { type: 'string', enum: ['open', 'accepted', 'completing', 'completed', 'cancelled'] },
|
|
581
|
+
before_work_id: { type: 'string' },
|
|
582
|
+
limit: { type: 'integer', description: 'Maximum 100 Work records; defaults to 20.' },
|
|
583
|
+
},
|
|
584
|
+
output: JSON_OUTPUT,
|
|
585
|
+
isConcurrencySafe: () => true,
|
|
586
|
+
execute: async (args, exec) => jsonResult(service.listWork(requireAgent(exec.agent), {
|
|
587
|
+
...(args.direction !== undefined ? { direction: args.direction } : {}),
|
|
588
|
+
...(args.status !== undefined ? { status: args.status } : {}),
|
|
589
|
+
...(args.before_work_id !== undefined ? { beforeWorkId: args.before_work_id } : {}),
|
|
590
|
+
...(args.limit !== undefined ? { limit: args.limit } : {}),
|
|
591
|
+
}).then(result => ({ ...result, works: result.works.map(workSummary) }))),
|
|
592
|
+
}));
|
|
593
|
+
ctx.tools.register(defineTool({
|
|
594
|
+
name: 'bizagent_work_accept',
|
|
595
|
+
description: 'As the assigned Home, bind one formal Work to this exact DSH Session before executing or completing it. A second Session cannot take the same Work.',
|
|
596
|
+
parameters: { work_id: { type: 'string', required: true } },
|
|
597
|
+
output: JSON_OUTPUT,
|
|
598
|
+
execute: async (args, exec) => jsonResult(service.acceptWork(requireAgent(exec.agent), args.work_id)),
|
|
599
|
+
}));
|
|
600
|
+
ctx.tools.register(defineTool({
|
|
601
|
+
name: 'bizagent_work_read',
|
|
602
|
+
description: 'Read one formal Work and its request/result delivery status if the current Home is requester or assignee.',
|
|
603
|
+
parameters: { work_id: { type: 'string', required: true } },
|
|
604
|
+
output: JSON_OUTPUT,
|
|
605
|
+
isConcurrencySafe: () => true,
|
|
606
|
+
execute: async (args, exec) => jsonResult(service.readWork(requireAgent(exec.agent), args.work_id)),
|
|
607
|
+
}));
|
|
608
|
+
ctx.tools.register(defineTool({
|
|
609
|
+
name: 'bizagent_work_complete',
|
|
610
|
+
description: 'As the assigned Home, reserve and deliver the single formal Work result. Competing completions return the first reserved result; an ordinary Inbox reply cannot complete Work.',
|
|
611
|
+
parameters: {
|
|
612
|
+
work_id: { type: 'string', required: true },
|
|
613
|
+
subject: { type: 'string', required: true },
|
|
614
|
+
body: { type: 'string', required: true, description: 'Concrete deliverable and evidence, up to 15000 characters.' },
|
|
615
|
+
artifact_refs: { type: 'array', items: { type: 'string' }, description: 'Optional files under artifacts/ in the bound worker Workspace; up to 10 files of at most 8 MiB each.' },
|
|
616
|
+
},
|
|
617
|
+
output: JSON_OUTPUT,
|
|
618
|
+
execute: async (args, exec) => {
|
|
619
|
+
const result = await service.completeWork(requireAgent(exec.agent), {
|
|
620
|
+
workId: args.work_id, subject: args.subject, body: args.body,
|
|
621
|
+
...(args.artifact_refs !== undefined ? { artifactRefs: args.artifact_refs } : {}),
|
|
622
|
+
});
|
|
623
|
+
workRunner.releaseWhenIdle(args.work_id);
|
|
624
|
+
return JSON.parse(JSON.stringify(result));
|
|
625
|
+
},
|
|
626
|
+
}));
|
|
627
|
+
ctx.tools.register(defineTool({
|
|
628
|
+
name: 'bizagent_work_artifact_read',
|
|
629
|
+
description: 'Read a bounded byte range from a completed formal Work result artifact snapshot. Available to requester and assignee.',
|
|
630
|
+
parameters: {
|
|
631
|
+
work_id: { type: 'string', required: true },
|
|
632
|
+
path: { type: 'string', required: true, description: 'Artifact path recorded in the Work result.' },
|
|
633
|
+
offset: { type: 'integer', description: 'Byte offset, defaults to 0.' },
|
|
634
|
+
limit: { type: 'integer', description: 'Maximum bytes, from 1 to 65536. Defaults to 8192.' },
|
|
635
|
+
},
|
|
636
|
+
output: JSON_OUTPUT,
|
|
637
|
+
isConcurrencySafe: () => true,
|
|
638
|
+
execute: async (args, exec) => jsonResult(service.readWorkArtifact(requireAgent(exec.agent), {
|
|
639
|
+
workId: args.work_id, path: args.path,
|
|
640
|
+
...(args.offset !== undefined ? { offset: args.offset } : {}),
|
|
641
|
+
...(args.limit !== undefined ? { limit: args.limit } : {}),
|
|
642
|
+
})),
|
|
643
|
+
}));
|
|
644
|
+
ctx.tools.register(defineTool({
|
|
645
|
+
name: 'bizagent_work_output_eval',
|
|
646
|
+
description: 'Inspect frozen formal Work deliverables with deterministic empty-text and placeholder assertions. Each checked source cites retained SHA-256; skip is not pass.',
|
|
647
|
+
parameters: { work_id: { type: 'string', required: true } },
|
|
648
|
+
output: JSON_OUTPUT,
|
|
649
|
+
isConcurrencySafe: () => true,
|
|
650
|
+
execute: async (args, exec) => jsonResult(service.evaluateWorkOutput(requireAgent(exec.agent), args.work_id)),
|
|
651
|
+
}));
|
|
652
|
+
ctx.tools.register(defineTool({
|
|
653
|
+
name: 'bizagent_work_cancel',
|
|
654
|
+
description: 'As the requester Home, cancel an open or accepted Work with a reason and notify the assignee. Result-reserved or completed Work cannot be cancelled.',
|
|
655
|
+
parameters: {
|
|
656
|
+
work_id: { type: 'string', required: true },
|
|
657
|
+
reason: { type: 'string', required: true, description: 'Why this Work is no longer required.' },
|
|
658
|
+
},
|
|
659
|
+
output: JSON_OUTPUT,
|
|
660
|
+
execute: async (args, exec) => {
|
|
661
|
+
const result = await service.cancelWork(requireAgent(exec.agent), {
|
|
662
|
+
workId: args.work_id, reason: args.reason,
|
|
663
|
+
});
|
|
664
|
+
workRunner.releaseWhenIdle(args.work_id);
|
|
665
|
+
return JSON.parse(JSON.stringify(result));
|
|
666
|
+
},
|
|
667
|
+
}));
|
|
668
|
+
ctx.tools.register(defineTool({
|
|
669
|
+
name: 'bizagent_memory_search',
|
|
670
|
+
description: 'Search the current Agent Home\'s long-term asset index. Read a useful hit before relying on its body.',
|
|
671
|
+
parameters: {
|
|
672
|
+
query: { type: 'string', description: 'Optional case-insensitive text query.' },
|
|
673
|
+
kind: {
|
|
674
|
+
type: 'string',
|
|
675
|
+
enum: ['memory', 'insight', 'knowledge', 'method', 'identity'],
|
|
676
|
+
description: 'Optional asset kind filter.',
|
|
677
|
+
},
|
|
678
|
+
status: {
|
|
679
|
+
type: 'string',
|
|
680
|
+
enum: ['candidate', 'active', 'superseded', 'retired'],
|
|
681
|
+
description: 'Optional lifecycle filter. Defaults to active.',
|
|
682
|
+
},
|
|
683
|
+
limit: { type: 'integer', description: 'Maximum results, from 1 to 100. Defaults to 20.' },
|
|
684
|
+
},
|
|
685
|
+
output: JSON_OUTPUT,
|
|
686
|
+
isConcurrencySafe: () => true,
|
|
687
|
+
execute: async (args, exec) => jsonResult(service.searchMemory(requireAgent(exec.agent), {
|
|
688
|
+
...(args.query !== undefined ? { query: args.query } : {}),
|
|
689
|
+
...(args.kind !== undefined ? { kind: args.kind } : {}),
|
|
690
|
+
...(args.status !== undefined ? { status: args.status } : {}),
|
|
691
|
+
...(args.limit !== undefined ? { limit: args.limit } : {}),
|
|
692
|
+
})),
|
|
693
|
+
}));
|
|
694
|
+
ctx.tools.register(defineTool({
|
|
695
|
+
name: 'bizagent_memory_read',
|
|
696
|
+
description: 'Read one long-term asset body from the current Agent Home and record a retrieved receipt.',
|
|
697
|
+
parameters: {
|
|
698
|
+
asset_id: { type: 'string', required: true, description: 'Asset id returned by bizagent_memory_search.' },
|
|
699
|
+
},
|
|
700
|
+
output: JSON_OUTPUT,
|
|
701
|
+
isConcurrencySafe: () => true,
|
|
702
|
+
execute: async (args, exec) => jsonResult(service.readMemory(requireAgent(exec.agent), String(exec.callId), args.asset_id)),
|
|
703
|
+
}));
|
|
704
|
+
ctx.tools.register(defineTool({
|
|
705
|
+
name: 'bizagent_evidence_read',
|
|
706
|
+
description: 'Read validated evidence cited by one current-Home learning asset.',
|
|
707
|
+
parameters: {
|
|
708
|
+
asset_id: { type: 'string', required: true, description: 'Asset whose evidence should be inspected.' },
|
|
709
|
+
source_index: { type: 'integer', description: 'Zero-based sourceRefs index. Defaults to 0.' },
|
|
710
|
+
},
|
|
711
|
+
output: JSON_OUTPUT,
|
|
712
|
+
isConcurrencySafe: () => true,
|
|
713
|
+
execute: async (args, exec) => jsonResult(service.readEvidence(requireAgent(exec.agent), {
|
|
714
|
+
assetId: args.asset_id,
|
|
715
|
+
...(args.source_index !== undefined ? { sourceIndex: args.source_index } : {}),
|
|
716
|
+
})),
|
|
717
|
+
}));
|
|
718
|
+
ctx.tools.register(defineTool({
|
|
719
|
+
name: 'bizagent_memory_remember',
|
|
720
|
+
description: 'Save evidence-backed learning to the current Home. Use candidate for unverified learning; only active assets enter future session indexes.',
|
|
721
|
+
parameters: {
|
|
722
|
+
kind: {
|
|
723
|
+
type: 'string',
|
|
724
|
+
enum: ['memory', 'insight', 'knowledge', 'method'],
|
|
725
|
+
description: 'memory: contextual observation (default); insight: supported inference; knowledge: reusable facts; method: repeatable procedure.',
|
|
726
|
+
},
|
|
727
|
+
status: {
|
|
728
|
+
type: 'string',
|
|
729
|
+
enum: ['candidate', 'active'],
|
|
730
|
+
description: 'Use candidate when validation is still needed. Defaults to active for established observations and explicit corrections.',
|
|
731
|
+
},
|
|
732
|
+
description: {
|
|
733
|
+
type: 'string',
|
|
734
|
+
required: true,
|
|
735
|
+
description: 'One concise index line describing when this memory is useful.',
|
|
736
|
+
},
|
|
737
|
+
body: { type: 'string', required: true, description: 'The complete reusable observation.' },
|
|
738
|
+
tags: TAGS,
|
|
739
|
+
},
|
|
740
|
+
output: JSON_OUTPUT,
|
|
741
|
+
execute: async (args, exec) => jsonResult(service.remember(requireAgent(exec.agent), String(exec.callId), {
|
|
742
|
+
...(args.kind !== undefined ? { kind: args.kind } : {}),
|
|
743
|
+
...(args.status !== undefined ? { status: args.status } : {}),
|
|
744
|
+
description: args.description,
|
|
745
|
+
body: args.body,
|
|
746
|
+
...(args.tags !== undefined ? { tags: args.tags } : {}),
|
|
747
|
+
})),
|
|
748
|
+
}));
|
|
749
|
+
ctx.tools.register(defineTool({
|
|
750
|
+
name: 'bizagent_memory_update',
|
|
751
|
+
description: 'Revise, retire, or publish learning owned by the current Home. Revise preserves lifecycle status. Publish and retire change status only: revise first, then read and validate the candidate and publish that exact revision with expected_revision.',
|
|
752
|
+
parameters: {
|
|
753
|
+
asset_id: { type: 'string', required: true },
|
|
754
|
+
action: { type: 'string', required: true, enum: ['revise', 'retire', 'publish'] },
|
|
755
|
+
expected_revision: { type: 'integer', description: 'Revision returned by memory_read. Required for publish; recommended for revise/retire to reject stale edits.' },
|
|
756
|
+
description: { type: 'string', description: 'Replacement index description; revise only.' },
|
|
757
|
+
body: { type: 'string', description: 'Replacement body; revise only.' },
|
|
758
|
+
tags: TAGS,
|
|
759
|
+
},
|
|
760
|
+
output: JSON_OUTPUT,
|
|
761
|
+
execute: async (args, exec) => jsonResult(service.updateMemory(requireAgent(exec.agent), {
|
|
762
|
+
assetId: args.asset_id,
|
|
763
|
+
action: args.action,
|
|
764
|
+
...(args.expected_revision !== undefined ? { expectedRevision: args.expected_revision } : {}),
|
|
765
|
+
...(args.description !== undefined ? { description: args.description } : {}),
|
|
766
|
+
...(args.body !== undefined ? { body: args.body } : {}),
|
|
767
|
+
...(args.tags !== undefined ? { tags: args.tags } : {}),
|
|
768
|
+
})),
|
|
769
|
+
}));
|
|
770
|
+
ctx.tools.register(defineTool({
|
|
771
|
+
name: 'bizagent_memory_propose',
|
|
772
|
+
description: 'Propose evidence-backed learning to another Agent Home. Never writes the target Home directly.',
|
|
773
|
+
parameters: {
|
|
774
|
+
to_address: {
|
|
775
|
+
type: 'string',
|
|
776
|
+
required: true,
|
|
777
|
+
description: 'Canonical target such as role:growth-strategy.',
|
|
778
|
+
},
|
|
779
|
+
proposed_kind: {
|
|
780
|
+
type: 'string',
|
|
781
|
+
enum: ['memory', 'insight', 'knowledge', 'method'],
|
|
782
|
+
description: 'Suggested maturity. Defaults to memory.',
|
|
783
|
+
},
|
|
784
|
+
target_asset_id: { type: 'string',
|
|
785
|
+
description: 'Replace this active asset after opening its Home Frame; the proposal freezes its revision and body hash.' },
|
|
786
|
+
description: { type: 'string', required: true, description: 'One concise target index line.' },
|
|
787
|
+
body: { type: 'string', required: true, description: 'Full proposed content.' },
|
|
788
|
+
tags: TAGS,
|
|
789
|
+
},
|
|
790
|
+
output: JSON_OUTPUT,
|
|
791
|
+
execute: async (args, exec) => jsonResult(service.proposeMemory(requireAgent(exec.agent), String(exec.callId), {
|
|
792
|
+
toAddress: args.to_address,
|
|
793
|
+
...(args.proposed_kind !== undefined ? { proposedKind: args.proposed_kind } : {}),
|
|
794
|
+
...(args.target_asset_id !== undefined ? { targetAssetId: args.target_asset_id } : {}),
|
|
795
|
+
description: args.description,
|
|
796
|
+
body: args.body,
|
|
797
|
+
...(args.tags !== undefined ? { tags: args.tags } : {}),
|
|
798
|
+
})),
|
|
799
|
+
}));
|
|
800
|
+
ctx.tools.register(defineTool({
|
|
801
|
+
name: 'bizagent_knowledge_propose',
|
|
802
|
+
description: 'Propose shared product-line or platform Knowledge. A human administrator must publish it.',
|
|
803
|
+
parameters: {
|
|
804
|
+
scope: { type: 'string', required: true, enum: ['line', 'common'] },
|
|
805
|
+
line: { type: 'string', description: 'Product line ID, required for line scope.' },
|
|
806
|
+
description: { type: 'string', required: true },
|
|
807
|
+
body: { type: 'string', required: true },
|
|
808
|
+
},
|
|
809
|
+
output: JSON_OUTPUT,
|
|
810
|
+
execute: async (args, exec) => jsonResult(service.proposeSharedKnowledge(requireAgent(exec.agent), String(exec.callId), args.scope === 'line'
|
|
811
|
+
? { scope: 'line', line: args.line ?? '', description: args.description, body: args.body }
|
|
812
|
+
: { scope: 'common', description: args.description, body: args.body })),
|
|
813
|
+
}));
|
|
814
|
+
ctx.tools.register(defineTool({
|
|
815
|
+
name: 'bizagent_knowledge_search',
|
|
816
|
+
description: 'Search platform and authorized product-line shared Knowledge source indexes.',
|
|
817
|
+
parameters: { query: { type: 'string', description: 'Optional case-insensitive text query.' } },
|
|
818
|
+
output: JSON_OUTPUT,
|
|
819
|
+
isConcurrencySafe: () => true,
|
|
820
|
+
execute: async (args, exec) => jsonResult(service.searchSharedKnowledge(requireAgent(exec.agent), args.query)),
|
|
821
|
+
}));
|
|
822
|
+
ctx.tools.register(defineTool({
|
|
823
|
+
name: 'bizagent_knowledge_read',
|
|
824
|
+
description: 'Read one shared Knowledge document from its governed source directory.',
|
|
825
|
+
parameters: {
|
|
826
|
+
document_id: { type: 'string', required: true },
|
|
827
|
+
scope: { type: 'string', required: true, enum: ['line', 'common'] },
|
|
828
|
+
line: { type: 'string', description: 'Product line ID, required for line scope.' },
|
|
829
|
+
},
|
|
830
|
+
output: JSON_OUTPUT,
|
|
831
|
+
isConcurrencySafe: () => true,
|
|
832
|
+
execute: async (args, exec) => jsonResult(service.readSharedKnowledge(requireAgent(exec.agent), args.document_id, args.scope === 'line' ? { scope: 'line', line: args.line ?? '' } : { scope: 'common' })),
|
|
833
|
+
}));
|
|
834
|
+
ctx.tools.register(defineTool({
|
|
835
|
+
name: 'bizagent_knowledge_proposals',
|
|
836
|
+
description: 'List shared Knowledge proposals visible to the current Agent Home.',
|
|
837
|
+
parameters: {
|
|
838
|
+
status: { type: 'string', enum: ['pending', 'accepted', 'rejected'] },
|
|
839
|
+
},
|
|
840
|
+
output: JSON_OUTPUT,
|
|
841
|
+
isConcurrencySafe: () => true,
|
|
842
|
+
execute: async (args, exec) => jsonResult(service.sharedKnowledgeProposals(requireAgent(exec.agent), args.status)),
|
|
843
|
+
}));
|
|
844
|
+
ctx.tools.register(defineTool({
|
|
845
|
+
name: 'bizagent_proposals',
|
|
846
|
+
description: 'List or inspect memory proposals visible to the current Agent Home.',
|
|
847
|
+
parameters: {
|
|
848
|
+
id: { type: 'string', description: 'Read one proposal by id.' },
|
|
849
|
+
direction: { type: 'string', enum: ['incoming', 'outgoing', 'both'], description: 'Defaults to incoming.' },
|
|
850
|
+
status: { type: 'string', enum: ['pending', 'accepted', 'rejected', 'withdrawn'] },
|
|
851
|
+
},
|
|
852
|
+
output: JSON_OUTPUT,
|
|
853
|
+
isConcurrencySafe: () => true,
|
|
854
|
+
execute: async (args, exec) => jsonResult(service.proposals(requireAgent(exec.agent), {
|
|
855
|
+
...(args.id !== undefined ? { id: args.id } : {}),
|
|
856
|
+
...(args.direction !== undefined ? { direction: args.direction } : {}),
|
|
857
|
+
...(args.status !== undefined ? { status: args.status } : {}),
|
|
858
|
+
})),
|
|
859
|
+
}));
|
|
860
|
+
ctx.tools.register(defineTool({
|
|
861
|
+
name: 'bizagent_learning_checkpoint',
|
|
862
|
+
description: 'Settle one BizAgent-issued explicit-correction checkpoint. Use exactly once when prompted by BizAgent.',
|
|
863
|
+
parameters: {
|
|
864
|
+
checkpoint_id: { type: 'string', required: true },
|
|
865
|
+
action: { type: 'string', required: true, enum: ['remember', 'skip'] },
|
|
866
|
+
description: { type: 'string', description: 'Required concise retrieval description for remember.' },
|
|
867
|
+
body: { type: 'string', description: 'Required reusable rule or preference for remember.' },
|
|
868
|
+
tags: TAGS,
|
|
869
|
+
decision: { type: 'string', description: 'Required reason for skip; optional rationale for remember.' },
|
|
870
|
+
},
|
|
871
|
+
output: JSON_OUTPUT,
|
|
872
|
+
execute: async (args, exec) => {
|
|
873
|
+
const result = await service.settleLearningCheckpoint(requireAgent(exec.agent), {
|
|
874
|
+
checkpointId: args.checkpoint_id,
|
|
875
|
+
action: args.action,
|
|
876
|
+
...(args.description !== undefined ? { description: args.description } : {}),
|
|
877
|
+
...(args.body !== undefined ? { body: args.body } : {}),
|
|
878
|
+
...(args.tags !== undefined ? { tags: args.tags } : {}),
|
|
879
|
+
...(args.decision !== undefined ? { decision: args.decision } : {}),
|
|
880
|
+
});
|
|
881
|
+
exec.concludeTurn();
|
|
882
|
+
return JSON.parse(JSON.stringify(result));
|
|
883
|
+
},
|
|
884
|
+
}));
|
|
885
|
+
ctx.tools.register(defineTool({
|
|
886
|
+
name: 'bizagent_memory_use_outcomes',
|
|
887
|
+
description: 'Inspect whether a Home asset was read or self-reported as applied before completed formal Work in the same worker Session. Shows source checks and submitted results, without assigning benefit.',
|
|
888
|
+
parameters: {
|
|
889
|
+
asset_id: { type: 'string', required: true },
|
|
890
|
+
before_work_id: { type: 'string', description: 'Cursor returned by a previous use-outcomes page.' },
|
|
891
|
+
limit: { type: 'integer', description: 'Maximum completed Work results, from 1 to 100. Defaults to 20.' },
|
|
892
|
+
},
|
|
893
|
+
output: JSON_OUTPUT,
|
|
894
|
+
isConcurrencySafe: () => true,
|
|
895
|
+
execute: async (args, exec) => jsonResult(service.memoryUseOutcomes(requireAgent(exec.agent), {
|
|
896
|
+
assetId: args.asset_id,
|
|
897
|
+
...(args.before_work_id !== undefined ? { beforeWorkId: args.before_work_id } : {}),
|
|
898
|
+
...(args.limit !== undefined ? { limit: args.limit } : {}),
|
|
899
|
+
})),
|
|
900
|
+
}));
|
|
901
|
+
ctx.tools.register(defineTool({
|
|
902
|
+
name: 'bizagent_memory_feedback',
|
|
903
|
+
description: 'Record whether a recalled asset was applied, confirmed, contradicted, or failed in the current work.',
|
|
904
|
+
parameters: {
|
|
905
|
+
asset_id: { type: 'string', required: true },
|
|
906
|
+
signal: {
|
|
907
|
+
type: 'string',
|
|
908
|
+
required: true,
|
|
909
|
+
enum: ['applied', 'confirmed', 'contradicted', 'failed'],
|
|
910
|
+
},
|
|
911
|
+
outcome: { type: 'string', description: 'Short evidence-backed outcome note.' },
|
|
912
|
+
},
|
|
913
|
+
output: JSON_OUTPUT,
|
|
914
|
+
execute: async (args, exec) => jsonResult(service.feedback(requireAgent(exec.agent), String(exec.callId), {
|
|
915
|
+
assetId: args.asset_id,
|
|
916
|
+
signal: args.signal,
|
|
917
|
+
...(args.outcome !== undefined ? { outcome: args.outcome } : {}),
|
|
918
|
+
})),
|
|
919
|
+
}));
|
|
920
|
+
}
|
|
921
|
+
function requireAgent(agent) {
|
|
922
|
+
if (agent === undefined)
|
|
923
|
+
throw new Error('BizAgent tools require a live DSH Agent session');
|
|
924
|
+
return agent;
|
|
925
|
+
}
|
|
926
|
+
/** One line per Project in lists; the full record stays one bizagent_project_read away. */
|
|
927
|
+
function projectSummary(project) {
|
|
928
|
+
return {
|
|
929
|
+
id: project.id, title: project.title, status: project.status, lead: project.lead,
|
|
930
|
+
revision: project.revision, goal: clip(project.goal, 240),
|
|
931
|
+
seats: (project.seats ?? []).map(seat => ({ homeAddress: seat.homeAddress, status: seat.status })),
|
|
932
|
+
claims: project.claims.length,
|
|
933
|
+
...(project.currentClaimId !== undefined ? { currentClaimId: project.currentClaimId } : {}),
|
|
934
|
+
...(project.acceptedClaimId !== undefined ? { acceptedClaimId: project.acceptedClaimId } : {}),
|
|
935
|
+
updatedAt: project.updatedAt,
|
|
936
|
+
};
|
|
937
|
+
}
|
|
938
|
+
/** Work without its long acceptance criteria and result body; bizagent_work_read returns those. */
|
|
939
|
+
function workSummary(work) {
|
|
940
|
+
return {
|
|
941
|
+
id: work.id, goal: work.goal, status: work.status, requester: work.requester, assignee: work.assignee,
|
|
942
|
+
...(work.projectId !== undefined ? { projectId: work.projectId } : {}),
|
|
943
|
+
...(work.resultMessageId !== undefined ? { resultMessageId: work.resultMessageId } : {}),
|
|
944
|
+
...(work.resultSubject !== undefined ? { resultSubject: work.resultSubject } : {}),
|
|
945
|
+
...(work.resultArtifacts !== undefined ? { resultArtifacts: work.resultArtifacts.length } : {}),
|
|
946
|
+
updatedAt: work.updatedAt,
|
|
947
|
+
};
|
|
948
|
+
}
|
|
949
|
+
function clip(text, max) {
|
|
950
|
+
return text.length <= max ? text : `${text.slice(0, max - 1)}…`;
|
|
951
|
+
}
|
|
952
|
+
async function jsonResult(value) {
|
|
953
|
+
return JSON.parse(JSON.stringify(await value));
|
|
954
|
+
}
|
|
955
|
+
//# sourceMappingURL=tools.js.map
|