@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
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { SessionEvent } from '@deepseek-ai/dsh-session';
|
|
2
|
+
import type { EvidenceRef } from './domain.js';
|
|
3
|
+
export interface LearningTriggerMatch {
|
|
4
|
+
reason: 'explicit-correction';
|
|
5
|
+
evidenceRef: Extract<EvidenceRef, {
|
|
6
|
+
type: 'session-events';
|
|
7
|
+
}>;
|
|
8
|
+
excerpt: string;
|
|
9
|
+
}
|
|
10
|
+
export interface LearningTrigger {
|
|
11
|
+
readonly name: string;
|
|
12
|
+
detect(events: readonly SessionEvent[], turn: number): LearningTriggerMatch | undefined;
|
|
13
|
+
}
|
|
14
|
+
export declare class ExplicitCorrectionTrigger implements LearningTrigger {
|
|
15
|
+
readonly name = "explicit-correction";
|
|
16
|
+
detect(events: readonly SessionEvent[], turn: number): LearningTriggerMatch | undefined;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=learning-trigger.d.ts.map
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
const EXPLICIT_CORRECTION_PATTERNS = [
|
|
2
|
+
/(?:请)?记住(?:这(?:一点|一条|件事)?|[\s::,,。]|$)/u,
|
|
3
|
+
/(?:从现在起|以后|下次).{0,40}(?:必须|应该|要|请|不要|不能|别)/u,
|
|
4
|
+
/(?:不要|别)再/u,
|
|
5
|
+
/(?:刚才|前面|上次).{0,50}(?:错了|不对|错误)/u,
|
|
6
|
+
/(?:正确的?(?:做法|方式|规则)|应该改成)/u,
|
|
7
|
+
/\b(?:please\s+)?remember\b/i,
|
|
8
|
+
/\bfrom now on\b/i,
|
|
9
|
+
/\bnext time\b.{0,80}\b(?:must|should|please|do not|don't|never)\b/i,
|
|
10
|
+
/\b(?:do not|don't|never)\b.{0,80}\bagain\b/i,
|
|
11
|
+
/\b(?:that|this|your previous).{0,40}\b(?:was|is)\s+(?:wrong|incorrect)\b/i,
|
|
12
|
+
];
|
|
13
|
+
export class ExplicitCorrectionTrigger {
|
|
14
|
+
name = 'explicit-correction';
|
|
15
|
+
detect(events, turn) {
|
|
16
|
+
const startIndex = findTurnStart(events, turn);
|
|
17
|
+
if (startIndex < 0)
|
|
18
|
+
return undefined;
|
|
19
|
+
const nextTurn = events.findIndex((event, index) => index > startIndex && event.type === 'turn/start');
|
|
20
|
+
const turnEvents = events.slice(startIndex, nextTurn < 0 ? undefined : nextTurn);
|
|
21
|
+
for (let index = turnEvents.length - 1; index >= 0; index -= 1) {
|
|
22
|
+
const event = turnEvents[index];
|
|
23
|
+
if (event?.type !== 'user/message' || event.data.source.kind !== 'user')
|
|
24
|
+
continue;
|
|
25
|
+
const text = textContent(event.data.content).trim();
|
|
26
|
+
if (text.length === 0 || !EXPLICIT_CORRECTION_PATTERNS.some(pattern => pattern.test(text)))
|
|
27
|
+
continue;
|
|
28
|
+
// Dispatch alone is not learning: failed, aborted, or unfinished writes must
|
|
29
|
+
// still reach the checkpoint. A later correction also needs its own write.
|
|
30
|
+
if (hasCompletedLearning(turnEvents, event.seq))
|
|
31
|
+
return undefined;
|
|
32
|
+
return {
|
|
33
|
+
reason: 'explicit-correction',
|
|
34
|
+
evidenceRef: {
|
|
35
|
+
type: 'session-events',
|
|
36
|
+
sessionId: '',
|
|
37
|
+
fromSeq: event.seq,
|
|
38
|
+
toSeq: event.seq,
|
|
39
|
+
},
|
|
40
|
+
excerpt: boundText(text, 4000),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function hasCompletedLearning(events, afterSeq) {
|
|
47
|
+
const calls = new Set();
|
|
48
|
+
const codeStarts = new Map();
|
|
49
|
+
const isLearningTool = (name) => name === 'bizagent_memory_remember'
|
|
50
|
+
|| name === 'bizagent_learning_checkpoint';
|
|
51
|
+
for (const raw of events) {
|
|
52
|
+
// Programmatic tool calls are dispatch events declared by dsh-tools, outside the session union.
|
|
53
|
+
const event = raw;
|
|
54
|
+
if (event.type === 'tool/ptc-dispatch-start')
|
|
55
|
+
codeStarts.set(event.data.subCallId, event.seq);
|
|
56
|
+
if (event.seq <= afterSeq)
|
|
57
|
+
continue;
|
|
58
|
+
if (event.type === 'tool/call' && isLearningTool(event.data.name))
|
|
59
|
+
calls.add(event.data.callId);
|
|
60
|
+
if (event.type === 'tool/result' && event.data.error === undefined) {
|
|
61
|
+
const result = event.data.message;
|
|
62
|
+
if (calls.has(result.toolCallId) && !result.isError)
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
if (event.type === 'tool/ptc-dispatch' && isLearningTool(event.data.name)
|
|
66
|
+
&& !event.data.isError && (codeStarts.get(event.data.subCallId) ?? event.seq) > afterSeq)
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
function findTurnStart(events, turn) {
|
|
72
|
+
for (let index = events.length - 1; index >= 0; index -= 1) {
|
|
73
|
+
const event = events[index];
|
|
74
|
+
if (event?.type === 'turn/start' && event.data.turn === turn)
|
|
75
|
+
return index;
|
|
76
|
+
}
|
|
77
|
+
return -1;
|
|
78
|
+
}
|
|
79
|
+
function textContent(content) {
|
|
80
|
+
return content.flatMap((block) => {
|
|
81
|
+
if (typeof block !== 'object' || block === null)
|
|
82
|
+
return [];
|
|
83
|
+
const candidate = block;
|
|
84
|
+
return candidate.type === 'text' && typeof candidate.text === 'string' ? [candidate.text] : [];
|
|
85
|
+
}).join('\n');
|
|
86
|
+
}
|
|
87
|
+
function boundText(value, maxChars) {
|
|
88
|
+
if (value.length <= maxChars)
|
|
89
|
+
return value;
|
|
90
|
+
return `${value.slice(0, Math.max(0, maxChars - 1))}…`;
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=learning-trigger.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { SessionEvent } from '@deepseek-ai/dsh-session';
|
|
2
|
+
/** A projection of the dedicated worker's durable model-call evidence. No price is inferred. */
|
|
3
|
+
export interface LearningUsage {
|
|
4
|
+
status: 'reported' | 'partial' | 'unavailable';
|
|
5
|
+
reported?: {
|
|
6
|
+
inputTokens: number;
|
|
7
|
+
outputTokens: number;
|
|
8
|
+
cacheReadTokens: number;
|
|
9
|
+
cacheWriteTokens: number;
|
|
10
|
+
reasoningTokens: number;
|
|
11
|
+
};
|
|
12
|
+
reportedSteps: number;
|
|
13
|
+
unreportedSteps: number;
|
|
14
|
+
lastEventSeq: number | null;
|
|
15
|
+
costUsd: null;
|
|
16
|
+
}
|
|
17
|
+
export declare function summarizeLearningUsage(events: readonly SessionEvent[]): LearningUsage;
|
|
18
|
+
//# sourceMappingURL=learning-usage.d.ts.map
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export function summarizeLearningUsage(events) {
|
|
2
|
+
const steps = new Map();
|
|
3
|
+
for (const event of events) {
|
|
4
|
+
if (event.type !== 'step/start' && event.type !== 'assistant/attempt'
|
|
5
|
+
&& event.type !== 'assistant/message')
|
|
6
|
+
continue;
|
|
7
|
+
const key = `${event.data.turn}:${event.data.step}`;
|
|
8
|
+
const step = steps.get(key) ?? { started: false, usages: [] };
|
|
9
|
+
if (event.type === 'step/start')
|
|
10
|
+
step.started = true;
|
|
11
|
+
else {
|
|
12
|
+
// Each model attempt (failed retries included) counts once: its streamed usage reports,
|
|
13
|
+
// or the message's own total when the adapter reported no usage chunk.
|
|
14
|
+
const streamed = (event.data.stream ?? []).flatMap(record => record.type === 'chunk' && record.chunk.type === 'usage' ? [record.chunk.usage] : []);
|
|
15
|
+
if (streamed.length > 0)
|
|
16
|
+
step.usages.push(...streamed);
|
|
17
|
+
else if (event.type === 'assistant/message' && event.data.usage !== undefined)
|
|
18
|
+
step.usages.push(event.data.usage);
|
|
19
|
+
}
|
|
20
|
+
steps.set(key, step);
|
|
21
|
+
}
|
|
22
|
+
const reported = { inputTokens: 0, outputTokens: 0,
|
|
23
|
+
cacheReadTokens: 0, cacheWriteTokens: 0, reasoningTokens: 0 };
|
|
24
|
+
let reportedSteps = 0;
|
|
25
|
+
let unreportedSteps = 0;
|
|
26
|
+
for (const step of steps.values()) {
|
|
27
|
+
const usages = step.usages;
|
|
28
|
+
if (usages.length === 0) {
|
|
29
|
+
if (step.started)
|
|
30
|
+
unreportedSteps += 1;
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
reportedSteps += 1;
|
|
34
|
+
for (const usage of usages) {
|
|
35
|
+
reported.inputTokens += usage.inputTokens;
|
|
36
|
+
reported.outputTokens += usage.outputTokens;
|
|
37
|
+
reported.cacheReadTokens += usage.cacheReadTokens ?? 0;
|
|
38
|
+
reported.cacheWriteTokens += usage.cacheWriteTokens ?? 0;
|
|
39
|
+
reported.reasoningTokens += usage.reasoningTokens ?? 0;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
status: reportedSteps === 0 ? 'unavailable' : unreportedSteps > 0 ? 'partial' : 'reported',
|
|
44
|
+
...(reportedSteps > 0 ? { reported } : {}),
|
|
45
|
+
reportedSteps, unreportedSteps,
|
|
46
|
+
lastEventSeq: events.at(-1)?.seq ?? null, costUsd: null,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=learning-usage.js.map
|
package/lib/ledger.d.ts
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { type DomainFacility } from '@deepseek-ai/dsh-storage-domain';
|
|
2
|
+
import { type SharedKnowledgeProposal } from './shared-knowledge.js';
|
|
3
|
+
import { type AgentFrameState, type InboxDelivery, type InboxHumanNotification, type HumanNotificationPreference, type UserAddress, type InboxMessage, type InboxWakeOrigin, type InboxWakePlan, type InboxReturnRoute, type FitnessReceipt, type LearningCheckpoint, type LearningMaterialObservation, type LearningMaterialReview, type LearningBatchRun, type LearningLaunch, type LearningScheduleCursor, type LearningSchedulePolicy, type MemoryProposal, type ProjectTurnParticipation, type SessionBinding } from './domain.js';
|
|
4
|
+
export declare const BIZAGENT_DOMAIN: {
|
|
5
|
+
name: string;
|
|
6
|
+
version: number;
|
|
7
|
+
tables: {
|
|
8
|
+
bindings: import("@deepseek-ai/dsh-storage-domain").DomainTableSpec<string, {
|
|
9
|
+
sessionId: string;
|
|
10
|
+
homeAddress: string;
|
|
11
|
+
boundAt: string;
|
|
12
|
+
cwd?: string | undefined;
|
|
13
|
+
}>;
|
|
14
|
+
proposals: import("@deepseek-ai/dsh-storage-domain").DomainTableSpec<string, {
|
|
15
|
+
id: string;
|
|
16
|
+
fromAddress: string;
|
|
17
|
+
toAddress: string;
|
|
18
|
+
proposedKind: "memory" | "insight" | "knowledge" | "method" | "identity";
|
|
19
|
+
description: string;
|
|
20
|
+
body: string;
|
|
21
|
+
tags: string[];
|
|
22
|
+
sourceRefs: ({
|
|
23
|
+
type: "session-events";
|
|
24
|
+
sessionId: string;
|
|
25
|
+
fromSeq: number;
|
|
26
|
+
toSeq: number;
|
|
27
|
+
} | {
|
|
28
|
+
type: "worklog";
|
|
29
|
+
sessionId: string;
|
|
30
|
+
revisionId: string;
|
|
31
|
+
fingerprint: string;
|
|
32
|
+
} | {
|
|
33
|
+
type: "tool-result";
|
|
34
|
+
sessionId: string;
|
|
35
|
+
eventSeq: number;
|
|
36
|
+
toolCallId: string;
|
|
37
|
+
} | {
|
|
38
|
+
type: "artifact";
|
|
39
|
+
uri: string;
|
|
40
|
+
digest: string;
|
|
41
|
+
} | {
|
|
42
|
+
type: "document";
|
|
43
|
+
uri: string;
|
|
44
|
+
digest: string;
|
|
45
|
+
authority?: string | undefined;
|
|
46
|
+
} | {
|
|
47
|
+
type: "asset";
|
|
48
|
+
ownerAddress: string;
|
|
49
|
+
assetId: string;
|
|
50
|
+
revision: number;
|
|
51
|
+
} | {
|
|
52
|
+
type: "user-confirmation";
|
|
53
|
+
sessionId: string;
|
|
54
|
+
eventSeq: number;
|
|
55
|
+
})[];
|
|
56
|
+
status: "rejected" | "pending" | "accepted" | "withdrawn";
|
|
57
|
+
createdAt: string;
|
|
58
|
+
baseAsset?: {
|
|
59
|
+
id: string;
|
|
60
|
+
revision: number;
|
|
61
|
+
bodySha256: string;
|
|
62
|
+
} | undefined;
|
|
63
|
+
targetAssetId?: string | undefined;
|
|
64
|
+
appliedAssetRevision?: number | undefined;
|
|
65
|
+
appliedBodySha256?: string | undefined;
|
|
66
|
+
humanReview?: {
|
|
67
|
+
reviewerId: string;
|
|
68
|
+
authorityRef: string;
|
|
69
|
+
action: "accept" | "reject";
|
|
70
|
+
decision: string;
|
|
71
|
+
reviewedAt: string;
|
|
72
|
+
} | undefined;
|
|
73
|
+
decision?: string | undefined;
|
|
74
|
+
decidedAt?: string | undefined;
|
|
75
|
+
}>;
|
|
76
|
+
receipts: import("@deepseek-ai/dsh-storage-domain").DomainTableSpec<string, {
|
|
77
|
+
id: string;
|
|
78
|
+
assetId: string;
|
|
79
|
+
ownerAddress: string;
|
|
80
|
+
sessionId: string;
|
|
81
|
+
signal: "retrieved" | "applied" | "confirmed" | "contradicted" | "failed";
|
|
82
|
+
createdAt: string;
|
|
83
|
+
eventSeq?: number | undefined;
|
|
84
|
+
assetRevision?: number | undefined;
|
|
85
|
+
assetBodySha256?: string | undefined;
|
|
86
|
+
outcome?: string | undefined;
|
|
87
|
+
}>;
|
|
88
|
+
metadata: import("@deepseek-ai/dsh-storage-domain").DomainTableSpec<string, {
|
|
89
|
+
key: string;
|
|
90
|
+
value: string;
|
|
91
|
+
updatedAt: string;
|
|
92
|
+
}>;
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
export declare class LearningLedger {
|
|
96
|
+
private readonly domain;
|
|
97
|
+
private receiptTail;
|
|
98
|
+
private learningBatchTail;
|
|
99
|
+
private readonly materialReviewWrites;
|
|
100
|
+
private readonly frameMutationTail;
|
|
101
|
+
private inboxMutationTail;
|
|
102
|
+
private projectTurnTail;
|
|
103
|
+
private proposalTail;
|
|
104
|
+
private constructor();
|
|
105
|
+
static open(facility: DomainFacility): Promise<LearningLedger>;
|
|
106
|
+
getBinding(sessionId: string): SessionBinding | undefined;
|
|
107
|
+
putBinding(binding: SessionBinding): Promise<void>;
|
|
108
|
+
/** Roll back a pre-creation reservation only after the host has verified that no Session materialized. */
|
|
109
|
+
removeUnmaterializedBinding(binding: SessionBinding): Promise<boolean>;
|
|
110
|
+
/** Forget a binding the current rules no longer make, so its Session binds afresh on its next turn. */
|
|
111
|
+
releaseBinding(binding: SessionBinding): Promise<boolean>;
|
|
112
|
+
listBindings(homeAddress?: string): SessionBinding[];
|
|
113
|
+
listProjectTurns(projectId?: string): ProjectTurnParticipation[];
|
|
114
|
+
putProjectTurn(input: Omit<ProjectTurnParticipation, 'schemaVersion' | 'recordedAt'>): Promise<ProjectTurnParticipation>;
|
|
115
|
+
getFrameState(sessionId: string): AgentFrameState | undefined;
|
|
116
|
+
updateFrameState(sessionId: string, update: (current: AgentFrameState | undefined) => AgentFrameState): Promise<AgentFrameState>;
|
|
117
|
+
withInboxWrite<T>(update: () => Promise<T>): Promise<T>;
|
|
118
|
+
getInboxMessage(id: string): InboxMessage | undefined;
|
|
119
|
+
listInboxMessages(): InboxMessage[];
|
|
120
|
+
putInboxMessage(message: InboxMessage): Promise<void>;
|
|
121
|
+
getInboxDelivery(messageId: string, recipient: string): InboxDelivery | undefined;
|
|
122
|
+
putInboxDelivery(delivery: InboxDelivery): Promise<void>;
|
|
123
|
+
getInboxHumanNotification(messageId: string, recipient: string): InboxHumanNotification | undefined;
|
|
124
|
+
getHumanNotificationPreference(recipient: string): HumanNotificationPreference | undefined;
|
|
125
|
+
setHumanNotificationPreference(recipient: string, enabled: boolean, expectedRevision: number): Promise<HumanNotificationPreference>;
|
|
126
|
+
/** The external provider was never called; this terminal record survives later opt-in. */
|
|
127
|
+
suppressInboxHumanNotification(messageId: string, recipient: string, reason: string): Promise<InboxHumanNotification>;
|
|
128
|
+
private putSuppressedHumanNotification;
|
|
129
|
+
/** Persist an opt-out while holding the same lock as preference updates and channel reservations. */
|
|
130
|
+
suppressInboxHumanNotificationIfOptedOut(messageId: string, recipient: UserAddress): Promise<InboxHumanNotification | undefined>;
|
|
131
|
+
/** Reserve before calling the channel; a crash leaves unknown and never causes an automatic resend. */
|
|
132
|
+
reserveInboxHumanNotification(messageId: string, recipient: string): Promise<{
|
|
133
|
+
notification: InboxHumanNotification;
|
|
134
|
+
reserved: boolean;
|
|
135
|
+
}>;
|
|
136
|
+
settleInboxHumanNotification(messageId: string, recipient: string, outcome: {
|
|
137
|
+
status: 'sent';
|
|
138
|
+
providerReceipt: string;
|
|
139
|
+
} | {
|
|
140
|
+
status: 'rejected';
|
|
141
|
+
reason: string;
|
|
142
|
+
}): Promise<InboxHumanNotification>;
|
|
143
|
+
/** A definite rejection permits one explicit new attempt; unknown and sent never do. */
|
|
144
|
+
retryRejectedInboxHumanNotification(messageId: string, recipient: string): Promise<InboxHumanNotification>;
|
|
145
|
+
getInboxWakeOrigin(sessionId: string): InboxWakeOrigin | undefined;
|
|
146
|
+
putInboxWakeOrigin(origin: InboxWakeOrigin): Promise<InboxWakeOrigin>;
|
|
147
|
+
getInboxWakePlan(id: string): InboxWakePlan | undefined;
|
|
148
|
+
listInboxWakePlans(): InboxWakePlan[];
|
|
149
|
+
/** Caller holds withInboxWrite so plan selection and reservation share one local writer. */
|
|
150
|
+
putInboxWakePlan(plan: InboxWakePlan): Promise<InboxWakePlan>;
|
|
151
|
+
markInboxWakeDispatched(id: string, dispatchedAt: string, retiredReason?: string): Promise<InboxWakePlan>;
|
|
152
|
+
getInboxReturnRoute(messageId: string, recipient: string): InboxReturnRoute | undefined;
|
|
153
|
+
putInboxReturnRoute(route: InboxReturnRoute): Promise<InboxReturnRoute>;
|
|
154
|
+
getMaterialObservation(id: string): LearningMaterialObservation | undefined;
|
|
155
|
+
putMaterialObservation(observation: LearningMaterialObservation): Promise<LearningMaterialObservation>;
|
|
156
|
+
getMaterialReview(materialId: string): LearningMaterialReview | undefined;
|
|
157
|
+
putMaterialReview(review: LearningMaterialReview): Promise<LearningMaterialReview>;
|
|
158
|
+
withLearningBatchWrite<T>(update: () => Promise<T>): Promise<T>;
|
|
159
|
+
getLearningBatch(id: string): LearningBatchRun | undefined;
|
|
160
|
+
listLearningBatches(homeAddress: string): LearningBatchRun[];
|
|
161
|
+
putLearningBatch(run: LearningBatchRun): Promise<LearningBatchRun>;
|
|
162
|
+
getLearningLaunch(id: string): LearningLaunch | undefined;
|
|
163
|
+
listLearningLaunches(homeAddress?: string): LearningLaunch[];
|
|
164
|
+
putLearningLaunch(launch: LearningLaunch): Promise<LearningLaunch>;
|
|
165
|
+
getLearningScheduleCursor(homeAddress: string): LearningScheduleCursor | undefined;
|
|
166
|
+
putLearningScheduleCursor(cursor: LearningScheduleCursor): Promise<LearningScheduleCursor>;
|
|
167
|
+
getLearningSchedulePolicy(homeAddress: string): LearningSchedulePolicy | undefined;
|
|
168
|
+
/** Caller holds the learning batch write lock and checks the prior revision. */
|
|
169
|
+
putLearningSchedulePolicy(policy: LearningSchedulePolicy): Promise<LearningSchedulePolicy>;
|
|
170
|
+
getProposal(id: string): MemoryProposal | undefined;
|
|
171
|
+
putProposal(proposal: MemoryProposal): Promise<void>;
|
|
172
|
+
listProposals(options?: {
|
|
173
|
+
fromAddress?: string;
|
|
174
|
+
toAddress?: string;
|
|
175
|
+
status?: MemoryProposal['status'];
|
|
176
|
+
}): MemoryProposal[];
|
|
177
|
+
getSharedKnowledgeProposal(id: string): SharedKnowledgeProposal | undefined;
|
|
178
|
+
listSharedKnowledgeProposals(status?: SharedKnowledgeProposal['status']): SharedKnowledgeProposal[];
|
|
179
|
+
putSharedKnowledgeProposal(input: SharedKnowledgeProposal): Promise<SharedKnowledgeProposal>;
|
|
180
|
+
putReceipt(receipt: FitnessReceipt): Promise<boolean>;
|
|
181
|
+
listReceipts(assetId?: string): FitnessReceipt[];
|
|
182
|
+
getCheckpoint(id: string): LearningCheckpoint | undefined;
|
|
183
|
+
putCheckpoint(checkpoint: LearningCheckpoint): Promise<void>;
|
|
184
|
+
listCheckpoints(options?: {
|
|
185
|
+
sessionId?: string;
|
|
186
|
+
homeAddress?: string;
|
|
187
|
+
status?: LearningCheckpoint['status'];
|
|
188
|
+
}): LearningCheckpoint[];
|
|
189
|
+
close(): Promise<void>;
|
|
190
|
+
}
|
|
191
|
+
//# sourceMappingURL=ledger.d.ts.map
|