@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.
Files changed (181) hide show
  1. package/CHANGELOG.md +124 -0
  2. package/LICENSE +21 -0
  3. package/README.md +61 -2
  4. package/cordis.patch.yml +14 -0
  5. package/docs/README.md +23 -0
  6. package/docs/architecture.md +154 -0
  7. package/docs/concepts.md +192 -0
  8. package/docs/configuration.md +154 -0
  9. package/docs/quickstart.md +103 -0
  10. package/docs/quickstart.zh-CN.md +86 -0
  11. package/docs/tools.md +607 -0
  12. package/docs/user-guide.zh-CN.md +132 -0
  13. package/docs/verification.md +69 -0
  14. package/examples/README.md +64 -0
  15. package/examples/demo-runtime.mjs +71 -0
  16. package/examples/learning-lab.mjs +263 -0
  17. package/examples/scenarios.mjs +45 -0
  18. package/lib/agent-preset.d.ts +20 -0
  19. package/lib/agent-preset.js +46 -0
  20. package/lib/agent-session-address.d.ts +14 -0
  21. package/lib/agent-session-address.js +15 -0
  22. package/lib/agent-session-coordinator.d.ts +24 -0
  23. package/lib/agent-session-coordinator.js +101 -0
  24. package/lib/cli.d.ts +3 -0
  25. package/lib/cli.js +142 -0
  26. package/lib/client-types/agent-session-address.d.ts +13 -0
  27. package/lib/client-types/client/agent-mentions.d.ts +3 -0
  28. package/lib/client-types/client/api.d.ts +180 -0
  29. package/lib/client-types/client/components.d.ts +22 -0
  30. package/lib/client-types/client/controller.d.ts +23 -0
  31. package/lib/client-types/client/frame-participants.d.ts +5 -0
  32. package/lib/client-types/client/home-name.d.ts +9 -0
  33. package/lib/client-types/client/human-inbox.d.ts +8 -0
  34. package/lib/client-types/client/index.d.ts +13 -0
  35. package/lib/client-types/client/locales.d.ts +796 -0
  36. package/lib/client-types/client/markdown.d.ts +12 -0
  37. package/lib/client-types/client/project-artifact-link.d.ts +10 -0
  38. package/lib/client-types/client/project-outcome-review-inbox.d.ts +13 -0
  39. package/lib/client-types/client/projects.d.ts +11 -0
  40. package/lib/client-types/client/sample-guide.d.ts +9 -0
  41. package/lib/client-types/client/session-resource.d.ts +34 -0
  42. package/lib/client-types/client/session-surfaces.d.ts +24 -0
  43. package/lib/client-types/client/styles.d.ts +1 -0
  44. package/lib/client-types/config.d.ts +55 -0
  45. package/lib/client-types/cron.d.ts +8 -0
  46. package/lib/client-types/domain.d.ts +818 -0
  47. package/lib/client-types/frame-reference.d.ts +4 -0
  48. package/lib/client-types/home-directory.d.ts +5 -0
  49. package/lib/client-types/home-space.d.ts +49 -0
  50. package/lib/client-types/home-store.d.ts +125 -0
  51. package/lib/client-types/inbox-stalled-topic.d.ts +15 -0
  52. package/lib/client-types/inbox-wake-policy.d.ts +18 -0
  53. package/lib/client-types/known-format.d.ts +2 -0
  54. package/lib/client-types/learning-scheduler.d.ts +36 -0
  55. package/lib/client-types/learning-session-runner.d.ts +49 -0
  56. package/lib/client-types/learning-trigger.d.ts +17 -0
  57. package/lib/client-types/learning-usage.d.ts +17 -0
  58. package/lib/client-types/ledger.d.ts +190 -0
  59. package/lib/client-types/local-owner.d.ts +7 -0
  60. package/lib/client-types/message-source.d.ts +9 -0
  61. package/lib/client-types/organization-location.d.ts +19 -0
  62. package/lib/client-types/project-ledger.d.ts +182 -0
  63. package/lib/client-types/project-seat-context.d.ts +17 -0
  64. package/lib/client-types/safe-file.d.ts +23 -0
  65. package/lib/client-types/sample-organization.d.ts +9 -0
  66. package/lib/client-types/service.d.ts +596 -0
  67. package/lib/client-types/shared-knowledge.d.ts +116 -0
  68. package/lib/client-types/ui-contract.d.ts +276 -0
  69. package/lib/client-types/untrusted-text.d.ts +15 -0
  70. package/lib/client-types/work-ledger.d.ts +108 -0
  71. package/lib/client-types/work-output-eval.d.ts +15 -0
  72. package/lib/client-types/worklog-ledger.d.ts +88 -0
  73. package/lib/client-types/worklog-snapshot.d.ts +33 -0
  74. package/lib/client.js +5463 -0
  75. package/lib/config.d.ts +56 -0
  76. package/lib/config.js +115 -0
  77. package/lib/cron.d.ts +9 -0
  78. package/lib/cron.js +127 -0
  79. package/lib/domain.d.ts +819 -0
  80. package/lib/domain.js +662 -0
  81. package/lib/frame-admission.d.ts +6 -0
  82. package/lib/frame-admission.js +39 -0
  83. package/lib/frame-reference.d.ts +5 -0
  84. package/lib/frame-reference.js +12 -0
  85. package/lib/home-archive.d.ts +17 -0
  86. package/lib/home-archive.js +177 -0
  87. package/lib/home-directory.d.ts +6 -0
  88. package/lib/home-directory.js +38 -0
  89. package/lib/home-space.d.ts +50 -0
  90. package/lib/home-space.js +120 -0
  91. package/lib/home-store.d.ts +126 -0
  92. package/lib/home-store.js +837 -0
  93. package/lib/host.d.ts +22 -0
  94. package/lib/host.js +15 -0
  95. package/lib/human-inbox-transport.d.ts +23 -0
  96. package/lib/human-inbox-transport.js +105 -0
  97. package/lib/human-notification-runner.d.ts +83 -0
  98. package/lib/human-notification-runner.js +138 -0
  99. package/lib/human-notification-webhook.d.ts +18 -0
  100. package/lib/human-notification-webhook.js +102 -0
  101. package/lib/human-turn-completion.d.ts +61 -0
  102. package/lib/human-turn-completion.js +157 -0
  103. package/lib/inbox-return-notifier.d.ts +46 -0
  104. package/lib/inbox-return-notifier.js +279 -0
  105. package/lib/inbox-stalled-escalation-runner.d.ts +31 -0
  106. package/lib/inbox-stalled-escalation-runner.js +68 -0
  107. package/lib/inbox-stalled-topic.d.ts +16 -0
  108. package/lib/inbox-stalled-topic.js +44 -0
  109. package/lib/inbox-wake-policy.d.ts +19 -0
  110. package/lib/inbox-wake-policy.js +28 -0
  111. package/lib/inbox-wake-runner.d.ts +45 -0
  112. package/lib/inbox-wake-runner.js +481 -0
  113. package/lib/index.d.ts +29 -0
  114. package/lib/index.js +480 -0
  115. package/lib/known-format.d.ts +3 -0
  116. package/lib/known-format.js +8 -0
  117. package/lib/learning-scheduler.d.ts +37 -0
  118. package/lib/learning-scheduler.js +182 -0
  119. package/lib/learning-session-runner.d.ts +50 -0
  120. package/lib/learning-session-runner.js +435 -0
  121. package/lib/learning-trigger.d.ts +18 -0
  122. package/lib/learning-trigger.js +92 -0
  123. package/lib/learning-usage.d.ts +18 -0
  124. package/lib/learning-usage.js +49 -0
  125. package/lib/ledger.d.ts +191 -0
  126. package/lib/ledger.js +752 -0
  127. package/lib/local-human-host.d.ts +11 -0
  128. package/lib/local-human-host.js +191 -0
  129. package/lib/local-human-token.d.ts +9 -0
  130. package/lib/local-human-token.js +32 -0
  131. package/lib/local-owner.d.ts +8 -0
  132. package/lib/local-owner.js +26 -0
  133. package/lib/message-source.d.ts +10 -0
  134. package/lib/message-source.js +2 -0
  135. package/lib/organization-location.d.ts +20 -0
  136. package/lib/organization-location.js +80 -0
  137. package/lib/organization-workspace.d.ts +22 -0
  138. package/lib/organization-workspace.js +32 -0
  139. package/lib/project-ledger.d.ts +183 -0
  140. package/lib/project-ledger.js +189 -0
  141. package/lib/project-review-transport.d.ts +23 -0
  142. package/lib/project-review-transport.js +155 -0
  143. package/lib/project-seat-context.d.ts +18 -0
  144. package/lib/project-seat-context.js +34 -0
  145. package/lib/proposal-review-transport.d.ts +26 -0
  146. package/lib/proposal-review-transport.js +104 -0
  147. package/lib/route-guard.d.ts +31 -0
  148. package/lib/route-guard.js +80 -0
  149. package/lib/safe-file.d.ts +24 -0
  150. package/lib/safe-file.js +93 -0
  151. package/lib/sample-organization.d.ts +10 -0
  152. package/lib/sample-organization.js +46 -0
  153. package/lib/service.d.ts +597 -0
  154. package/lib/service.js +4076 -0
  155. package/lib/session-surface.d.ts +11 -0
  156. package/lib/session-surface.js +109 -0
  157. package/lib/shared-knowledge-review-transport.d.ts +28 -0
  158. package/lib/shared-knowledge-review-transport.js +85 -0
  159. package/lib/shared-knowledge.d.ts +117 -0
  160. package/lib/shared-knowledge.js +240 -0
  161. package/lib/tools.d.ts +7 -0
  162. package/lib/tools.js +955 -0
  163. package/lib/ui-contract.d.ts +277 -0
  164. package/lib/ui-contract.js +12 -0
  165. package/lib/ui-host.d.ts +24 -0
  166. package/lib/ui-host.js +471 -0
  167. package/lib/untrusted-text.d.ts +16 -0
  168. package/lib/untrusted-text.js +50 -0
  169. package/lib/work-ledger.d.ts +109 -0
  170. package/lib/work-ledger.js +107 -0
  171. package/lib/work-output-eval.d.ts +16 -0
  172. package/lib/work-output-eval.js +58 -0
  173. package/lib/work-runner.d.ts +47 -0
  174. package/lib/work-runner.js +352 -0
  175. package/lib/worklog-ledger.d.ts +89 -0
  176. package/lib/worklog-ledger.js +91 -0
  177. package/lib/worklog-snapshot.d.ts +34 -0
  178. package/lib/worklog-snapshot.js +100 -0
  179. package/lib/writer-guard.d.ts +11 -0
  180. package/lib/writer-guard.js +207 -0
  181. package/package.json +172 -4
@@ -0,0 +1,597 @@
1
+ import type { Agent } from '@deepseek-ai/dsh-agent';
2
+ import type { SessionEvent } from '@deepseek-ai/dsh-session';
3
+ import type { SessionQueryEngine } from '@deepseek-ai/dsh-session-query';
4
+ import { type AgentFrameState, type AssetKind, type AssetStatus, type FitnessSignal, type FrameMode, type HomeAddress, type HumanAction, type HumanNotificationPreference, type InboxSenderAddress, type UserAddress, type InboxDelivery, type InboxMessage, type LearningCheckpoint, type MemoryProposal, type SessionBinding } from './domain.js';
5
+ import type { ResolvedConfig } from './config.js';
6
+ import { HomeStore, type CreateOrganizationInput } from './home-store.js';
7
+ import { HomeSpace } from './home-space.js';
8
+ import { LearningLedger } from './ledger.js';
9
+ import { WorkLedger, type FormalWork } from './work-ledger.js';
10
+ import { ProjectLedger, type FormalProject } from './project-ledger.js';
11
+ import type { UiProjectOutcomeReviewInbox } from './ui-contract.js';
12
+ import { type ProjectSeatContext } from './project-seat-context.js';
13
+ import { type SharedKnowledgeTarget, type SharedKnowledgeProposal } from './shared-knowledge.js';
14
+ import { WorklogLedger, type WorklogRevision } from './worklog-ledger.js';
15
+ import { type LearningTrigger } from './learning-trigger.js';
16
+ import { type ActiveOrganizationLocation } from './organization-location.js';
17
+ type MutableKind = Exclude<AssetKind, 'identity'>;
18
+ export interface FrameStatusSnapshot {
19
+ state: AgentFrameState;
20
+ refreshRequired: boolean;
21
+ staleFrames: HomeAddress[];
22
+ }
23
+ export interface MemoryUseOutcomePage {
24
+ homeAddress: HomeAddress;
25
+ assetId: string;
26
+ assetRevision: number;
27
+ currentBodySha256: string;
28
+ interpretation: string;
29
+ outcomes: Array<{
30
+ workId: string;
31
+ projectId?: string;
32
+ sessionId: string;
33
+ completedAt?: string;
34
+ resultSubject?: string;
35
+ resultBody?: string;
36
+ resultArtifacts: NonNullable<FormalWork['resultArtifacts']>;
37
+ workSourceStatus: 'verified' | 'changed' | 'unavailable';
38
+ omittedReceipts: number;
39
+ uses: Array<{
40
+ receiptId: string;
41
+ signal: 'retrieved' | 'applied';
42
+ sessionId: string;
43
+ eventSeq?: number;
44
+ assetRevision?: number;
45
+ assetBodySha256?: string;
46
+ observedAt: string;
47
+ sourceStatus: 'verified' | 'changed' | 'unavailable';
48
+ }>;
49
+ }>;
50
+ nextBeforeWorkId?: string;
51
+ }
52
+ type InboxSendInput = {
53
+ to: string[];
54
+ cc?: string[];
55
+ subject: string;
56
+ body: string;
57
+ priority?: 'normal' | 'urgent';
58
+ due?: string;
59
+ contextRefs?: string[];
60
+ humanAction?: HumanAction;
61
+ replyTo?: string;
62
+ projectId?: string;
63
+ idempotencyKey?: string;
64
+ kind?: InboxMessage['kind'];
65
+ internalReturnToSessionId?: string;
66
+ };
67
+ export declare class BizAgentService {
68
+ readonly ledger: LearningLedger;
69
+ readonly config: ResolvedConfig;
70
+ private readonly sessionQuery?;
71
+ private readonly learningTriggers;
72
+ private activeOrganization?;
73
+ readonly workLedger?: WorkLedger | undefined;
74
+ readonly projectLedger?: ProjectLedger | undefined;
75
+ readonly worklogLedger?: WorklogLedger | undefined;
76
+ projectMainProvisioner?: (projectId: string) => Promise<{
77
+ sessionId: string;
78
+ }>;
79
+ private readonly liveBindings;
80
+ /** Bounded, de-duplicated runtime issues; oldest are dropped first. */
81
+ private readonly runtimeIssues;
82
+ private sharedKnowledgeIndex;
83
+ private worklogRecoveryOffset;
84
+ private sessionWorklogRecoveryOffset;
85
+ constructor(store: HomeSpace | HomeStore, ledger: LearningLedger, config: ResolvedConfig, sessionQuery?: (Pick<SessionQueryEngine, "readSession"> & Partial<Pick<SessionQueryEngine, "listSessions">>) | undefined, learningTriggers?: readonly LearningTrigger[], activeOrganization?: ActiveOrganizationLocation | undefined, workLedger?: WorkLedger | undefined, projectLedger?: ProjectLedger | undefined, worklogLedger?: WorklogLedger | undefined);
86
+ store: HomeSpace;
87
+ initialize(): Promise<void>;
88
+ /**
89
+ * Before organizations had their own folder, every Session outside a Home folder fell back to the
90
+ * Business Home. Forget those bindings so the Sessions bind afresh, to the personal Home, on their
91
+ * next turn. Bindings the current rules still make are kept.
92
+ */
93
+ private releaseStrayBusinessBindings;
94
+ getActiveOrganizationLocation(): ActiveOrganizationLocation | undefined;
95
+ /**
96
+ * Where this Home's own Sessions run when BizAgent starts one (formal Work, Inbox wake): the host's
97
+ * explicit workspaceHomes mapping, else the active Home's own directory. Undefined when neither
98
+ * exists. The Home directory is the same Workspace its Principal and Project Main use.
99
+ */
100
+ homeWorkspaceRoot(home: HomeAddress): string | undefined;
101
+ /** A known Workspace whose new Sessions resolve to this active Business Home: the organization folder. */
102
+ chatWorkspacePath(home: HomeAddress): string | undefined;
103
+ /** Create an organization in its own folder, `<data root>/orgs/<id>`, and make it the active one. */
104
+ createOrganization(input: CreateOrganizationInput): Promise<void>;
105
+ /** Create the one-click sample team and place its sample data files. */
106
+ createSampleOrganization(): Promise<void>;
107
+ bindSession(sessionId: string, cwd?: string): SessionBinding | undefined;
108
+ contextForSession(sessionId: string, cwd?: string): string;
109
+ contextSnapshotForSession(sessionId: string, cwd?: string): {
110
+ homeAddress: HomeAddress;
111
+ revision: number;
112
+ digest: string;
113
+ text: string;
114
+ } | undefined;
115
+ homeStatus(agent: Agent): Promise<Record<string, unknown>>;
116
+ listEpisodes(agent: Agent, input?: {
117
+ beforeSessionId?: string;
118
+ limit?: number;
119
+ }): Promise<Record<string, unknown>>;
120
+ readEpisode(agent: Agent, input: {
121
+ sessionId: string;
122
+ afterSeq?: number;
123
+ limit?: number;
124
+ }): Promise<Record<string, unknown>>;
125
+ recordWorklog(agent: Agent, input: {
126
+ description: string;
127
+ body: string;
128
+ status: WorklogRevision['status'];
129
+ idempotencyKey: string;
130
+ files?: string[];
131
+ projectId?: string;
132
+ workId?: string;
133
+ }): Promise<Record<string, unknown>>;
134
+ /** Materialize completed formal Work after its completion turn is durable. */
135
+ reconcileCompletedWorklogs(limit?: number, sessionId?: string): Promise<{
136
+ created: string[];
137
+ deferred: string[];
138
+ failed: Array<{
139
+ workId: string;
140
+ error: unknown;
141
+ }>;
142
+ }>;
143
+ private materializeCompletedWorklog;
144
+ /** Record substantive ordinary turns from the persisted Session, including after a restart. */
145
+ reconcileSessionWorklogs(limit?: number, sessionId?: string): Promise<{
146
+ created: string[];
147
+ deferred: string[];
148
+ failed: Array<{
149
+ sessionId: string;
150
+ error: unknown;
151
+ }>;
152
+ }>;
153
+ searchWorklogs(agent: Agent, input?: {
154
+ query?: string;
155
+ status?: WorklogRevision['status'];
156
+ beforeSessionId?: string;
157
+ limit?: number;
158
+ }): Promise<Record<string, unknown>>;
159
+ readWorklog(agent: Agent, input: {
160
+ sessionId: string;
161
+ revision?: number;
162
+ }): Promise<Record<string, unknown>>;
163
+ readWorklogFile(agent: Agent, input: {
164
+ sessionId: string;
165
+ revision?: number;
166
+ path: string;
167
+ offset?: number;
168
+ limit?: number;
169
+ }): Promise<Record<string, unknown>>;
170
+ scanLearningMaterials(agent: Agent, input?: {
171
+ beforeSessionId?: string;
172
+ limit?: number;
173
+ }): Promise<Record<string, unknown>>;
174
+ /** Host scheduler preflight uses the same bounded source scan as the worker, without spending model tokens. */
175
+ hasPendingLearningMaterials(homeAddress: HomeAddress): Promise<boolean>;
176
+ private scanHomeLearningMaterials;
177
+ /**
178
+ * Snapshot the Home's identity and learning files. Retired assets are left out, except ones that
179
+ * were in the batch's starting snapshot, so a retirement during the batch shows as an update.
180
+ */
181
+ private captureLearningLibrary;
182
+ reviewLearningMaterial(agent: Agent, input: {
183
+ materialId: string;
184
+ summary: string;
185
+ }): Promise<Record<string, unknown>>;
186
+ startLearningBatch(agent: Agent, callId: string): Promise<Record<string, unknown>>;
187
+ learningBatchStatus(agent: Agent, runId: string): Promise<Record<string, unknown>>;
188
+ readLearningBatchChange(agent: Agent, input: {
189
+ runId: string;
190
+ path: string;
191
+ side: 'before' | 'after';
192
+ offset?: number;
193
+ limit?: number;
194
+ }): Promise<Record<string, unknown>>;
195
+ settleLearningBatchMaterial(agent: Agent, input: {
196
+ runId: string;
197
+ materialId: string;
198
+ summary: string;
199
+ candidates?: Array<{
200
+ kind: MutableKind;
201
+ description: string;
202
+ body: string;
203
+ fromSeq?: number;
204
+ toSeq?: number;
205
+ tags?: string[];
206
+ }>;
207
+ }): Promise<Record<string, unknown>>;
208
+ finishLearningBatch(agent: Agent, input: {
209
+ runId: string;
210
+ action: 'complete' | 'abandon';
211
+ summary: string;
212
+ }): Promise<Record<string, unknown>>;
213
+ private learningBatchView;
214
+ sendInboxMessage(agent: Agent, callId: string, input: InboxSendInput): Promise<Record<string, unknown>>;
215
+ /** Resolve a Project Seat delivery to its long-lived execution Home. */
216
+ inboxAddressHome(address: string, allowReleased?: boolean): HomeAddress | undefined;
217
+ projectSeatContextForAddress(address: string): ProjectSeatContext | undefined;
218
+ joinProjectTurn(agent: Agent, projectId: string): Promise<Record<string, unknown>>;
219
+ private recordProjectTurn;
220
+ private inboxDeliveryForHome;
221
+ private sendInboxFromBinding;
222
+ listInbox(agent: Agent, input?: {
223
+ direction?: 'incoming' | 'outgoing' | 'both';
224
+ pendingOnly?: boolean;
225
+ beforeMessageId?: string;
226
+ limit?: number;
227
+ }): Promise<Record<string, unknown>>;
228
+ pendingInboxDigestForSession(sessionId: string, cwd?: string): {
229
+ homeAddress: HomeAddress;
230
+ total: number;
231
+ digest: string;
232
+ messages: Array<{
233
+ id: string;
234
+ fromAddress: InboxSenderAddress;
235
+ subject: string;
236
+ kind: InboxMessage['kind'];
237
+ priority: 'normal' | 'urgent';
238
+ convergence?: {
239
+ topicId: string;
240
+ hop: number;
241
+ topicCount: number;
242
+ };
243
+ }>;
244
+ } | undefined;
245
+ readInboxMessage(agent: Agent, messageId: string): Promise<Record<string, unknown>>;
246
+ handleInboxMessage(agent: Agent, messageId: string): Promise<Record<string, unknown>>;
247
+ private inboxDeliveries;
248
+ /** Trusted host entrypoint; the owner and authority reference must come from verified identity state. */
249
+ createAutomaticTopicEscalation(input: {
250
+ topicId: string;
251
+ userId: string;
252
+ authorityRef: string;
253
+ now?: number;
254
+ }): Promise<{
255
+ message: InboxMessage;
256
+ delivery: InboxDelivery;
257
+ } | undefined>;
258
+ /** Call these human Inbox methods only after the host has authenticated the user. */
259
+ readHumanNotificationPreference(userId: string): {
260
+ recipient: UserAddress;
261
+ enabled: boolean;
262
+ revision: number;
263
+ updatedAt?: string;
264
+ };
265
+ setHumanNotificationPreference(userId: string, enabled: boolean, expectedRevision: number): Promise<{
266
+ preference: HumanNotificationPreference;
267
+ }>;
268
+ listHumanInbox(userId: string, input?: {
269
+ direction?: 'incoming' | 'outgoing' | 'both';
270
+ pendingOnly?: boolean;
271
+ beforeMessageId?: string;
272
+ limit?: number;
273
+ }): Record<string, unknown>;
274
+ readHumanInbox(userId: string, messageId: string): Record<string, unknown>;
275
+ handleHumanInbox(userId: string, messageId: string): Promise<Record<string, unknown>>;
276
+ replyHumanInbox(userId: string, input: {
277
+ replyTo: string;
278
+ subject: string;
279
+ body: string;
280
+ idempotencyKey: string;
281
+ }): Promise<Record<string, unknown>>;
282
+ createProject(agent: Agent, input: {
283
+ title: string;
284
+ goal: string;
285
+ doneWhen: string;
286
+ idempotencyKey: string;
287
+ }): Promise<Record<string, unknown>>;
288
+ listProjects(agent: Agent, input?: {
289
+ status?: FormalProject['status'];
290
+ beforeProjectId?: string;
291
+ limit?: number;
292
+ }): Promise<{
293
+ homeAddress: HomeAddress;
294
+ projects: FormalProject[];
295
+ nextBeforeProjectId?: string;
296
+ }>;
297
+ listProjectsForSession(sessionId: string, cwd: string | undefined, input?: {
298
+ status?: FormalProject['status'];
299
+ beforeProjectId?: string;
300
+ limit?: number;
301
+ }): Promise<{
302
+ homeAddress: HomeAddress;
303
+ projects: FormalProject[];
304
+ nextBeforeProjectId?: string;
305
+ }>;
306
+ readProject(agent: Agent, projectId: string): Promise<{
307
+ project: FormalProject;
308
+ work: FormalWork[];
309
+ }>;
310
+ readProjectForSession(sessionId: string, cwd: string | undefined, projectId: string): Promise<{
311
+ project: FormalProject;
312
+ work: FormalWork[];
313
+ }>;
314
+ inviteProjectSeat(agent: Agent, input: {
315
+ projectId: string;
316
+ homeAddress: string;
317
+ responsibility: string;
318
+ }): Promise<Record<string, unknown>>;
319
+ releaseProjectSeat(agent: Agent, input: {
320
+ projectId: string;
321
+ seatAddress: string;
322
+ }): Promise<Record<string, unknown>>;
323
+ readProjectArtifact(agent: Agent, input: {
324
+ projectId: string;
325
+ claimId: string;
326
+ path: string;
327
+ offset?: number;
328
+ limit?: number;
329
+ }): Promise<Record<string, unknown>>;
330
+ submitProject(agent: Agent, input: {
331
+ projectId: string;
332
+ summary: string;
333
+ body: string;
334
+ doneWhenAssessment: string;
335
+ artifactRefs?: string[];
336
+ }): Promise<Record<string, unknown>>;
337
+ reviewProject(agent: Agent, input: {
338
+ projectId: string;
339
+ claimId: string;
340
+ decision: 'accept' | 'rework';
341
+ reason: string;
342
+ }): Promise<Record<string, unknown>>;
343
+ /** Human review keeps the same settlement checks and records the verified Host principal. */
344
+ reviewProjectAsHuman(principal: string, input: {
345
+ projectId: string;
346
+ claimId: string;
347
+ expectedRevision: number;
348
+ decision: 'accept' | 'rework';
349
+ reason: string;
350
+ }, authorize: (principal: string, project: FormalProject) => boolean | Promise<boolean>): Promise<Record<string, unknown>>;
351
+ listPendingProjectOutcomeReviewsAsHuman(principal: string, authorize: (principal: string, project: FormalProject) => boolean | Promise<boolean>, offset?: number, limit?: number): Promise<UiProjectOutcomeReviewInbox>;
352
+ private decideProjectReview;
353
+ reconcileProjectOutcomeReworkNotifications(limit?: number): Promise<{
354
+ delivered: string[];
355
+ failed: Array<{
356
+ projectId: string;
357
+ claimId: string;
358
+ error: unknown;
359
+ }>;
360
+ }>;
361
+ private deliverProjectOutcomeReworkNotice;
362
+ dispatchWork(agent: Agent, input: {
363
+ toAddress: string;
364
+ goal: string;
365
+ acceptanceCriteria: string;
366
+ idempotencyKey: string;
367
+ projectId?: string;
368
+ }): Promise<Record<string, unknown>>;
369
+ private dispatchWorkRecord;
370
+ /**
371
+ * Why a worker Session must not be started automatically for this Work, or undefined when it may.
372
+ * Like Inbox wake, DSH has no per-start execution principal, so only Homes with the same explicit
373
+ * owner may start work in each other's mapped Workspace. Other Work stays open for the
374
+ * assignee's own Sessions.
375
+ */
376
+ workAutoStartBlock(requester: HomeAddress, assignee: HomeAddress): 'no-workspace-mapping' | 'different-owner' | undefined;
377
+ /** True only when both Homes exist and carry the same non-empty owner. */
378
+ sameHomeOwner(left: HomeAddress, right: HomeAddress): boolean;
379
+ listWork(agent: Agent, input?: {
380
+ direction?: 'assigned' | 'requested' | 'both';
381
+ status?: FormalWork['status'];
382
+ beforeWorkId?: string;
383
+ limit?: number;
384
+ }): Promise<{
385
+ homeAddress: HomeAddress;
386
+ works: FormalWork[];
387
+ nextBeforeWorkId: string | undefined;
388
+ }>;
389
+ acceptWork(agent: Agent, workId: string): Promise<Record<string, unknown>>;
390
+ readWork(agent: Agent, workId: string): Promise<Record<string, unknown>>;
391
+ readWorkArtifact(agent: Agent, input: {
392
+ workId: string;
393
+ path: string;
394
+ offset?: number;
395
+ limit?: number;
396
+ }): Promise<Record<string, unknown>>;
397
+ evaluateWorkOutput(agent: Agent, workId: string): Promise<Record<string, unknown>>;
398
+ private requireWorkOutputAccess;
399
+ cancelWork(agent: Agent, input: {
400
+ workId: string;
401
+ reason: string;
402
+ }): Promise<Record<string, unknown>>;
403
+ completeWork(agent: Agent, input: {
404
+ workId: string;
405
+ subject: string;
406
+ body: string;
407
+ artifactRefs?: string[];
408
+ }): Promise<Record<string, unknown>>;
409
+ /** Rebuild Work notices from durable reservations before restarting reserved workers. */
410
+ reconcileWorkNotifications(): Promise<{
411
+ repaired: {
412
+ workId: string;
413
+ phase: 'request' | 'result' | 'cancel';
414
+ }[];
415
+ failed: {
416
+ workId: string;
417
+ phase: 'request' | 'result' | 'cancel';
418
+ error: unknown;
419
+ }[];
420
+ }>;
421
+ private workNoticeMissing;
422
+ private requireWorkSenderBinding;
423
+ private finishWorkCompletion;
424
+ private requireWorkNotification;
425
+ private requireWorkLedger;
426
+ private requireProjectLedger;
427
+ private requireWorklogLedger;
428
+ private requireInboxDelivered;
429
+ frameStatus(agent: Agent): Promise<FrameStatusSnapshot>;
430
+ frameStatusForSession(sessionId: string, cwd: string | undefined, events: readonly SessionEvent[]): Promise<FrameStatusSnapshot>;
431
+ private frameStatusSnapshot;
432
+ searchHomes(agent: Agent, input?: {
433
+ query?: string;
434
+ limit?: number;
435
+ }): Promise<Record<string, unknown>>;
436
+ searchHomesForSession(sessionId: string, cwd: string | undefined, input?: {
437
+ query?: string;
438
+ limit?: number;
439
+ }): Promise<Record<string, unknown>>;
440
+ resolveHomeForSession(sessionId: string, cwd: string | undefined, target: string): Promise<Record<string, unknown>>;
441
+ openFrame(agent: Agent, input: {
442
+ address: string;
443
+ mode?: FrameMode;
444
+ refresh?: boolean;
445
+ /** Host admission retries need a full snapshot without invalidating other fresh Frames. */
446
+ forceSnapshot?: boolean;
447
+ }): Promise<Record<string, unknown>>;
448
+ searchFrame(agent: Agent, input: {
449
+ address?: string;
450
+ query?: string;
451
+ kind?: AssetKind;
452
+ limit?: number;
453
+ }): Promise<Record<string, unknown>>;
454
+ readFrame(agent: Agent, callId: string, input: {
455
+ address?: string;
456
+ assetId: string;
457
+ }): Promise<Record<string, unknown>>;
458
+ closeFrame(agent: Agent, address?: string): Promise<Record<string, unknown>>;
459
+ searchMemory(agent: Agent, input: {
460
+ query?: string;
461
+ kind?: AssetKind;
462
+ status?: AssetStatus;
463
+ limit?: number;
464
+ }): Promise<Record<string, unknown>>;
465
+ readMemory(agent: Agent, callId: string, assetId: string): Promise<Record<string, unknown>>;
466
+ private sharedKnowledgeTargets;
467
+ private searchSharedKnowledgeLayers;
468
+ private refreshSharedKnowledgeIndex;
469
+ private renderSharedKnowledgeIndex;
470
+ private verifiedSharedKnowledgeDocument;
471
+ searchSharedKnowledge(agent: Agent, query?: string): Promise<Record<string, unknown>>;
472
+ readSharedKnowledge(agent: Agent, documentId: string, target: SharedKnowledgeTarget): Promise<Record<string, unknown>>;
473
+ proposeSharedKnowledge(agent: Agent, callId: string, input: SharedKnowledgeTarget & {
474
+ description: string;
475
+ body: string;
476
+ }): Promise<Record<string, unknown>>;
477
+ sharedKnowledgeProposals(agent: Agent, status?: SharedKnowledgeProposal['status']): Promise<Record<string, unknown>>;
478
+ decideSharedKnowledgeAsHuman(input: {
479
+ proposalId: string;
480
+ action: 'accept' | 'reject';
481
+ decision: string;
482
+ reviewerId: string;
483
+ authorityRef: string;
484
+ }): Promise<Record<string, unknown>>;
485
+ /** Inspect later formal Work in the same worker Session without assigning a benefit score. */
486
+ memoryUseOutcomes(agent: Agent, input: {
487
+ assetId: string;
488
+ beforeWorkId?: string;
489
+ limit?: number;
490
+ }): Promise<MemoryUseOutcomePage>;
491
+ memoryUseOutcomesForSession(sessionId: string, cwd: string | undefined, input: {
492
+ assetId: string;
493
+ beforeWorkId?: string;
494
+ limit?: number;
495
+ }): Promise<MemoryUseOutcomePage>;
496
+ private memoryUseOutcomesForHome;
497
+ remember(agent: Agent, callId: string, input: {
498
+ kind?: MutableKind;
499
+ status?: 'candidate' | 'active';
500
+ description: string;
501
+ body: string;
502
+ tags?: string[];
503
+ }): Promise<Record<string, unknown>>;
504
+ updateMemory(agent: Agent, input: {
505
+ assetId: string;
506
+ action: 'revise' | 'retire' | 'publish';
507
+ expectedRevision?: number;
508
+ description?: string;
509
+ body?: string;
510
+ tags?: string[];
511
+ }): Promise<Record<string, unknown>>;
512
+ proposeMemory(agent: Agent, callId: string, input: {
513
+ toAddress: string;
514
+ proposedKind?: MutableKind;
515
+ targetAssetId?: string;
516
+ description: string;
517
+ body: string;
518
+ tags?: string[];
519
+ }): Promise<Record<string, unknown>>;
520
+ proposals(agent: Agent, input: {
521
+ id?: string;
522
+ direction?: 'incoming' | 'outgoing' | 'both';
523
+ status?: MemoryProposal['status'];
524
+ }): Promise<Record<string, unknown>>;
525
+ acceptProposal(agent: Agent, input: {
526
+ proposalId: string;
527
+ kind?: MutableKind;
528
+ description?: string;
529
+ body?: string;
530
+ tags?: string[];
531
+ decision?: string;
532
+ }): Promise<Record<string, unknown>>;
533
+ /** Call only after the host authenticates the human and authorizes this exact target Home. */
534
+ decideProposalAsHuman(input: {
535
+ ownerAddress: string;
536
+ proposalId: string;
537
+ action: 'accept' | 'reject';
538
+ decision: string;
539
+ reviewerId: string;
540
+ authorityRef: string;
541
+ }): Promise<Record<string, unknown>>;
542
+ private acceptProposalForHome;
543
+ prepareLearningCheckpoint(agent: Agent, turn: number): Promise<LearningCheckpoint | undefined>;
544
+ settleLearningCheckpoint(agent: Agent, input: {
545
+ checkpointId: string;
546
+ action: 'remember' | 'skip';
547
+ description?: string;
548
+ body?: string;
549
+ tags?: string[];
550
+ decision?: string;
551
+ }): Promise<Record<string, unknown>>;
552
+ failPendingCheckpoint(sessionId: string, turn: number, decision: string): Promise<void>;
553
+ readEvidence(agent: Agent, input: {
554
+ assetId: string;
555
+ sourceIndex?: number;
556
+ }): Promise<Record<string, unknown>>;
557
+ feedback(agent: Agent, callId: string, input: {
558
+ assetId: string;
559
+ signal: FitnessSignal;
560
+ outcome?: string;
561
+ }): Promise<Record<string, unknown>>;
562
+ /**
563
+ * Fitness is derived from the asset's receipts, so concurrent feedback cannot lose an update and
564
+ * a retried call applies its receipt exactly once. A concurrent asset write is retried.
565
+ */
566
+ private settleFitness;
567
+ close(): Promise<void>;
568
+ recordRuntimeError(scope: string, error: unknown, home?: HomeAddress): void;
569
+ /** Every recorded runtime issue, oldest first, for operators (overview health). */
570
+ listRuntimeIssues(): RuntimeIssue[];
571
+ private addRuntimeIssue;
572
+ private requireDurableBinding;
573
+ private requireDurableSessionBinding;
574
+ private resolveHome;
575
+ private frameState;
576
+ private checkedFrameState;
577
+ private requireReadableFrameHome;
578
+ private requireOpenFrameAddress;
579
+ private requireTargetProposal;
580
+ private receipt;
581
+ private reconcileProposals;
582
+ private reconcileSharedKnowledgeProposals;
583
+ private reconcileCheckpoints;
584
+ }
585
+ export interface RuntimeIssue {
586
+ message: string;
587
+ /** The Home the issue belongs to, when known; unattributed issues are shown to operators only. */
588
+ home?: HomeAddress;
589
+ count: number;
590
+ firstAt: string;
591
+ lastAt: string;
592
+ }
593
+ export declare function renderRuntimeIssue(issue: RuntimeIssue): string;
594
+ export declare function isAssetKind(value: string): value is AssetKind;
595
+ export declare function isFitnessSignal(value: string): value is FitnessSignal;
596
+ export {};
597
+ //# sourceMappingURL=service.d.ts.map