@steerable/agent-shell 0.12.8 → 0.14.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/dist/attachments/image-normalizer.d.ts +39 -0
- package/dist/attachments/image-normalizer.js +131 -0
- package/dist/auth/credentials.d.ts +83 -0
- package/dist/auth/credentials.js +426 -0
- package/dist/auth/index.d.ts +33 -9
- package/dist/auth/index.js +85 -0
- package/dist/host/external-pack-loader.d.ts +40 -0
- package/dist/host/external-pack-loader.js +247 -0
- package/dist/host/http-routes.d.ts +6 -2
- package/dist/host/http-routes.js +5 -2
- package/dist/host/pack-assembly.d.ts +9 -1
- package/dist/host/runtime.js +54 -1
- package/dist/image-attachment.js +10 -5
- package/dist/local-backend/coreloop-stream.d.ts +4 -0
- package/dist/local-backend/coreloop-stream.js +4 -0
- package/dist/local-backend/fact-chain.d.ts +38 -0
- package/dist/local-backend/fact-chain.js +145 -0
- package/dist/local-backend/router.d.ts +3 -1
- package/dist/local-backend/router.js +602 -45
- package/dist/local-backend/state-reconcile.d.ts +42 -0
- package/dist/local-backend/state-reconcile.js +81 -0
- package/dist/local-backend/title-refresh.d.ts +39 -0
- package/dist/local-backend/title-refresh.js +80 -0
- package/dist/local-backend/turn-security-context.d.ts +42 -0
- package/dist/local-backend/turn-security-context.js +62 -0
- package/dist/local-backend/ui-surface.d.ts +75 -0
- package/dist/local-backend/ui-surface.js +368 -0
- package/dist/local-executor.d.ts +3 -0
- package/dist/local-executor.js +40 -1
- package/dist/memory/authoring-candidates.d.ts +26 -0
- package/dist/memory/authoring-candidates.js +73 -0
- package/dist/memory/injector.d.ts +38 -0
- package/dist/memory/injector.js +122 -0
- package/dist/memory/routes.d.ts +16 -0
- package/dist/memory/routes.js +146 -0
- package/dist/memory/store.d.ts +176 -0
- package/dist/memory/store.js +623 -0
- package/dist/memory/tools.d.ts +83 -0
- package/dist/memory/tools.js +143 -0
- package/dist/present-files.d.ts +25 -1
- package/dist/present-files.js +170 -2
- package/dist/raster-image.d.ts +7 -1
- package/dist/raster-image.js +34 -0
- package/dist/scenario/applications.d.ts +52 -0
- package/dist/scenario/applications.js +143 -0
- package/dist/scenario/pack.d.ts +1 -1
- package/dist/security/policy-digest.d.ts +28 -0
- package/dist/security/policy-digest.js +104 -0
- package/dist/server/http-server.js +23 -6
- package/dist/sidecar/boot.d.ts +1 -0
- package/dist/sidecar/boot.js +2 -0
- package/dist/sidecar/index.d.ts +1 -1
- package/dist/sidecar/rejected-before-effect.d.ts +22 -0
- package/dist/sidecar/rejected-before-effect.js +63 -0
- package/dist/sidecar/reverse-approval.d.ts +2 -0
- package/dist/sidecar/reverse-approval.js +28 -5
- package/dist/sidecar/reverse-tools.d.ts +3 -0
- package/dist/sidecar/reverse-tools.js +146 -18
- package/dist/sidecar/supervisor.d.ts +31 -1
- package/dist/sidecar/supervisor.js +47 -0
- package/dist/sidecar/types.d.ts +72 -0
- package/dist/storage/fde-fallback.d.ts +4 -0
- package/dist/storage/fde-fallback.js +354 -0
- package/dist/storage/fde-types.d.ts +215 -0
- package/dist/storage/fde-types.js +1 -0
- package/dist/storage/index.d.ts +113 -1
- package/dist/storage/index.js +797 -0
- package/dist/storage/insights-redact.d.ts +4 -1
- package/dist/storage/insights-redact.js +6 -1
- package/dist/storage/process-locks.d.ts +1 -1
- package/dist/storage/process-locks.js +1 -1
- package/dist/storage/reliability-summary.d.ts +1 -1
- package/dist/storage/scoped-store.d.ts +3 -1
- package/dist/tool-presentation.js +20 -0
- package/dist/tool-router.d.ts +20 -1
- package/dist/tool-router.js +76 -12
- package/package.json +5 -5
|
@@ -126,6 +126,10 @@ export function toTurnTool(schema) {
|
|
|
126
126
|
const category = schema.approval?.category;
|
|
127
127
|
if (category)
|
|
128
128
|
tool.approvalCategory = category;
|
|
129
|
+
if (schema.idempotent !== undefined)
|
|
130
|
+
tool.idempotent = schema.idempotent;
|
|
131
|
+
if (schema.checkpoint)
|
|
132
|
+
tool.checkpoint = schema.checkpoint;
|
|
129
133
|
return tool;
|
|
130
134
|
}
|
|
131
135
|
/**
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ScopedStore } from '../storage/scoped-store.js';
|
|
2
|
+
export interface FactChainGraphDto {
|
|
3
|
+
readonly chatId: string;
|
|
4
|
+
readonly targetKind: 'message' | 'tool' | 'deliverable';
|
|
5
|
+
readonly targetId: string;
|
|
6
|
+
readonly requestNode: {
|
|
7
|
+
readonly status: 'recorded' | 'gap';
|
|
8
|
+
readonly model?: string;
|
|
9
|
+
readonly policyDigest?: string;
|
|
10
|
+
readonly systemPromptSummary?: string;
|
|
11
|
+
readonly attachmentHashes?: readonly string[];
|
|
12
|
+
readonly gapReason?: string;
|
|
13
|
+
};
|
|
14
|
+
readonly evidenceStatus: 'recorded' | 'no_tool_evidence' | 'gap';
|
|
15
|
+
readonly toolNodes: readonly {
|
|
16
|
+
readonly id: string;
|
|
17
|
+
readonly toolName: string;
|
|
18
|
+
readonly argsSummary: string;
|
|
19
|
+
readonly status: 'executed' | 'outcome_unknown' | 'failed';
|
|
20
|
+
readonly durationMs?: number;
|
|
21
|
+
}[];
|
|
22
|
+
readonly deliverableNode?: {
|
|
23
|
+
readonly id: string;
|
|
24
|
+
readonly fileName: string;
|
|
25
|
+
readonly filePath: string;
|
|
26
|
+
readonly verificationStatus: 'verified' | 'warnings' | 'failed' | 'unverified';
|
|
27
|
+
readonly verifierSummary?: string | null;
|
|
28
|
+
readonly snapshotSha256: string;
|
|
29
|
+
readonly workspaceState: 'unchanged' | 'modified' | 'deleted';
|
|
30
|
+
readonly snapshotDownloadUrl?: string | null;
|
|
31
|
+
} | null;
|
|
32
|
+
}
|
|
33
|
+
export declare function assembleFactChainGraph(options: {
|
|
34
|
+
readonly store: ScopedStore;
|
|
35
|
+
readonly chatId: string;
|
|
36
|
+
readonly targetKind: 'message' | 'tool' | 'deliverable';
|
|
37
|
+
readonly targetId: string;
|
|
38
|
+
}): Promise<FactChainGraphDto>;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read-only Execution Provenance (`FactChainGraph`) assembler (R5-2).
|
|
3
|
+
*
|
|
4
|
+
* Reconstructs `requestNode -> toolNodes[] -> deliverableNode` strictly from
|
|
5
|
+
* authoritative host/ledger records without fabricating citations from assistant
|
|
6
|
+
* prose:
|
|
7
|
+
* - Missing request snapshot (e.g., imported legacy transcript) -> `status: 'gap'`
|
|
8
|
+
* - Zero tool calls in the turn -> `evidenceStatus: 'no_tool_evidence'`
|
|
9
|
+
* - Verified deliverable -> compares live workspace file SHA-256 against archived
|
|
10
|
+
* `snapshotSha256` to report `'unchanged' | 'modified' | 'deleted'`.
|
|
11
|
+
*/
|
|
12
|
+
import { createHash } from 'node:crypto';
|
|
13
|
+
import fs from 'node:fs/promises';
|
|
14
|
+
import { ensurePhase9Store } from '../storage/fde-fallback.js';
|
|
15
|
+
async function computeFileSha256OrNull(filePath) {
|
|
16
|
+
try {
|
|
17
|
+
const bytes = await fs.readFile(filePath);
|
|
18
|
+
return createHash('sha256').update(bytes).digest('hex');
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
async function buildDeliverableNode(chatId, deliv) {
|
|
25
|
+
const liveHash = await computeFileSha256OrNull(deliv.filePath);
|
|
26
|
+
const workspaceState = liveHash === null
|
|
27
|
+
? 'deleted'
|
|
28
|
+
: liveHash === deliv.sha256
|
|
29
|
+
? 'unchanged'
|
|
30
|
+
: 'modified';
|
|
31
|
+
return {
|
|
32
|
+
id: deliv.id,
|
|
33
|
+
fileName: deliv.fileName,
|
|
34
|
+
filePath: deliv.filePath,
|
|
35
|
+
verificationStatus: deliv.verificationStatus,
|
|
36
|
+
verifierSummary: deliv.summary,
|
|
37
|
+
snapshotSha256: deliv.sha256,
|
|
38
|
+
workspaceState,
|
|
39
|
+
snapshotDownloadUrl: deliv.reportPath
|
|
40
|
+
? `/api/v2/chats/${encodeURIComponent(chatId)}/deliverables/${encodeURIComponent(deliv.id)}/snapshot`
|
|
41
|
+
: null,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export async function assembleFactChainGraph(options) {
|
|
45
|
+
const p9 = ensurePhase9Store(options.store);
|
|
46
|
+
const messages = await options.store.listMessages(options.chatId, 200);
|
|
47
|
+
const deliverables = await p9.listChatDeliverables(options.chatId);
|
|
48
|
+
let matchedDeliverable;
|
|
49
|
+
if (options.targetKind === 'deliverable') {
|
|
50
|
+
matchedDeliverable = deliverables.find((d) => d.id === options.targetId);
|
|
51
|
+
}
|
|
52
|
+
let matchedMessage = options.targetKind === 'message'
|
|
53
|
+
? messages.find((m) => m.id === options.targetId)
|
|
54
|
+
: matchedDeliverable?.messageId
|
|
55
|
+
? messages.find((m) => m.id === matchedDeliverable.messageId)
|
|
56
|
+
: undefined;
|
|
57
|
+
if (!matchedMessage && options.targetKind === 'tool') {
|
|
58
|
+
matchedMessage = messages.find((m) => {
|
|
59
|
+
if (!m.messageMetadata)
|
|
60
|
+
return false;
|
|
61
|
+
return m.messageMetadata.includes(options.targetId);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
if (!matchedMessage) {
|
|
65
|
+
matchedMessage = messages.find((m) => m.role === 'assistant');
|
|
66
|
+
}
|
|
67
|
+
if (!matchedDeliverable && matchedMessage) {
|
|
68
|
+
matchedDeliverable =
|
|
69
|
+
deliverables.find((d) => d.messageId === matchedMessage.id) ?? deliverables[0];
|
|
70
|
+
}
|
|
71
|
+
let meta = null;
|
|
72
|
+
if (matchedMessage?.messageMetadata) {
|
|
73
|
+
try {
|
|
74
|
+
const parsed = JSON.parse(matchedMessage.messageMetadata);
|
|
75
|
+
if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
|
|
76
|
+
meta = parsed;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
meta = null;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const importedWithoutSnapshot = !meta ||
|
|
84
|
+
meta.imported === true ||
|
|
85
|
+
(meta.model === undefined &&
|
|
86
|
+
meta.traceId === undefined &&
|
|
87
|
+
meta.executedActions === undefined &&
|
|
88
|
+
meta.policyDigest === undefined);
|
|
89
|
+
const requestNode = importedWithoutSnapshot
|
|
90
|
+
? {
|
|
91
|
+
status: 'gap',
|
|
92
|
+
gapReason: 'imported_without_request_snapshot',
|
|
93
|
+
}
|
|
94
|
+
: {
|
|
95
|
+
status: 'recorded',
|
|
96
|
+
...(typeof meta?.model === 'string' ? { model: meta.model } : {}),
|
|
97
|
+
...(typeof meta?.policyDigest === 'string'
|
|
98
|
+
? { policyDigest: meta.policyDigest }
|
|
99
|
+
: {}),
|
|
100
|
+
...(Array.isArray(meta?.attachmentHashes)
|
|
101
|
+
? {
|
|
102
|
+
attachmentHashes: meta.attachmentHashes.filter((h) => typeof h === 'string'),
|
|
103
|
+
}
|
|
104
|
+
: {}),
|
|
105
|
+
};
|
|
106
|
+
const rawActions = Array.isArray(meta?.executedActions)
|
|
107
|
+
? meta.executedActions
|
|
108
|
+
: [];
|
|
109
|
+
const toolNodes = rawActions.map((act, idx) => {
|
|
110
|
+
const id = typeof act.id === 'string' && act.id ? act.id : `tool_${idx + 1}`;
|
|
111
|
+
const toolName = String(act.tool ?? act.name ?? 'unknown');
|
|
112
|
+
const argsSummary = act.arguments ? JSON.stringify(act.arguments).slice(0, 200) : '';
|
|
113
|
+
const isUnknown = act.outcomeUnknown === true ||
|
|
114
|
+
(typeof act.error === 'string' && act.error.includes('outcome_unknown'));
|
|
115
|
+
const status = isUnknown
|
|
116
|
+
? 'outcome_unknown'
|
|
117
|
+
: act.success === false
|
|
118
|
+
? 'failed'
|
|
119
|
+
: 'executed';
|
|
120
|
+
return {
|
|
121
|
+
id,
|
|
122
|
+
toolName,
|
|
123
|
+
argsSummary,
|
|
124
|
+
status,
|
|
125
|
+
...(typeof act.durationMs === 'number' ? { durationMs: act.durationMs } : {}),
|
|
126
|
+
};
|
|
127
|
+
});
|
|
128
|
+
const evidenceStatus = importedWithoutSnapshot && toolNodes.length === 0
|
|
129
|
+
? 'gap'
|
|
130
|
+
: toolNodes.length === 0
|
|
131
|
+
? 'no_tool_evidence'
|
|
132
|
+
: 'recorded';
|
|
133
|
+
const deliverableNode = matchedDeliverable
|
|
134
|
+
? await buildDeliverableNode(options.chatId, matchedDeliverable)
|
|
135
|
+
: null;
|
|
136
|
+
return {
|
|
137
|
+
chatId: options.chatId,
|
|
138
|
+
targetKind: options.targetKind,
|
|
139
|
+
targetId: options.targetId,
|
|
140
|
+
requestNode,
|
|
141
|
+
evidenceStatus,
|
|
142
|
+
toolNodes,
|
|
143
|
+
deliverableNode,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
@@ -4,7 +4,7 @@ import { ToolRouter } from '../tool-router.js';
|
|
|
4
4
|
import { type ResolvedAsk } from '../sidecar/reverse-ask-user.js';
|
|
5
5
|
import type { TaskService } from './task-service.js';
|
|
6
6
|
import { type PackBackendBinaryResponse } from './pack-backend-routes.js';
|
|
7
|
-
import { type Principal } from '../auth/index.js';
|
|
7
|
+
import { type OriginChannel, type Principal } from '../auth/index.js';
|
|
8
8
|
export interface LocalBackendRequest {
|
|
9
9
|
method: string;
|
|
10
10
|
path: string;
|
|
@@ -13,6 +13,8 @@ export interface LocalBackendRequest {
|
|
|
13
13
|
headers?: Record<string, string | string[] | undefined>;
|
|
14
14
|
/** Authenticated identity supplied by the BS HTTP layer. */
|
|
15
15
|
principal?: Principal;
|
|
16
|
+
/** Originating channel ('desktop' | 'web' | 'cli' | 'im' | 'webhook'). */
|
|
17
|
+
originChannel?: OriginChannel;
|
|
16
18
|
}
|
|
17
19
|
export interface LocalBackendResponse<T = unknown> {
|
|
18
20
|
status: number;
|