omp-superagent 0.1.9 → 0.1.10
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/DESIGN.md +10 -6
- package/README.ko.md +28 -377
- package/README.md +30 -425
- package/config.example.json +7 -0
- package/docs/OPERATIONS.en.md +2223 -0
- package/docs/OPERATIONS.md +104 -5
- package/docs/design/execution.md +85 -4
- package/docs/design/messaging.md +12 -2
- package/docs/kakao-bridge-protocol.md +193 -0
- package/docs/releases/0.1.10.md +17 -0
- package/gateway/bin/omp-gateway-darwin-arm64 +0 -0
- package/gateway/bin/omp-gateway-darwin-x64 +0 -0
- package/gateway/bin/omp-gateway-linux-arm64 +0 -0
- package/gateway/bin/omp-gateway-linux-x64 +0 -0
- package/host-owner/bin/omp-host-owner-darwin-arm64 +0 -0
- package/host-owner/bin/omp-host-owner-darwin-x64 +0 -0
- package/host-owner/bin/omp-host-owner-linux-arm64 +0 -0
- package/host-owner/bin/omp-host-owner-linux-x64 +0 -0
- package/package.json +1 -1
- package/skills/head/SKILL.md +25 -3
- package/skills/head/references/supervision.md +9 -0
- package/skills/lane/SKILL.md +11 -0
- package/skills/lane/references/workflow.md +9 -0
- package/src/cli.ts +2 -0
- package/src/config.ts +44 -3
- package/src/contracts.ts +30 -1
- package/src/extension.ts +22 -4
- package/src/host-extension.ts +50 -8
- package/src/host-protocol.ts +1 -0
- package/src/host-reply-voice.ts +181 -0
- package/src/lane-extension.ts +46 -8
- package/src/lane-report.ts +22 -0
- package/src/message-order.ts +2 -1
- package/src/runtime.ts +428 -71
- package/src/setup.ts +2 -1
- package/src/soul.ts +214 -0
- package/src/store.ts +381 -13
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import type { AgentSession, ExtensionAPI } from "@oh-my-pi/pi-coding-agent";
|
|
4
|
+
import { isUserAuthoredMessage } from "@oh-my-pi/pi-coding-agent/session/messages";
|
|
5
|
+
import type { Frame } from "./host-protocol";
|
|
6
|
+
import { renderReplyVoice } from "./soul";
|
|
7
|
+
|
|
8
|
+
type Message = AgentSession["messages"][number];
|
|
9
|
+
type StagedVoice = { readonly token: string; readonly digest: string; readonly voice: string };
|
|
10
|
+
type Binding = StagedVoice & { readonly phase: "staged" | "input" | "submitted" };
|
|
11
|
+
type Submission = {
|
|
12
|
+
readonly token: string;
|
|
13
|
+
kind: "prompt" | "local-command" | "command-prompt";
|
|
14
|
+
admitted: boolean; prepared?: string;
|
|
15
|
+
};
|
|
16
|
+
const wirePrefix = "\0omp-superagent-reply-voice:";
|
|
17
|
+
|
|
18
|
+
const digest = (text: string) => createHash("sha256").update(text).digest("hex");
|
|
19
|
+
const messageText = (message: Extract<Message, { role: "user" }>) =>
|
|
20
|
+
typeof message.content === "string" ? message.content
|
|
21
|
+
: message.content.flatMap(part => part.type === "text" ? [part.text] : []).join("");
|
|
22
|
+
|
|
23
|
+
/** Project into the root's provider call, not its stored or effective session prompt. */
|
|
24
|
+
export function installReplyVoice(pi: ExtensionAPI, session: AgentSession, claim: (token: string) => Promise<boolean>,
|
|
25
|
+
retire: (token: string) => void) {
|
|
26
|
+
const { agent, sessionId, sessionFile, extensionRunner: runner } = session;
|
|
27
|
+
if (typeof agent.addBeforeModelCallHook !== "function" || typeof agent.streamFn !== "function"
|
|
28
|
+
|| typeof session.prompt !== "function" || typeof session.addDisposer !== "function"
|
|
29
|
+
|| typeof session.subscribeRunState !== "function" || !runner || typeof runner.emitInput !== "function") return;
|
|
30
|
+
const sameSession = () => session.sessionId === sessionId && session.sessionFile === sessionFile && !session.isDisposed;
|
|
31
|
+
const idle = () => sameSession() && !session.isRunActive && !session.isBusyForSnapshot
|
|
32
|
+
&& !session.hasAdmittedSubmission && !session.hasPostPromptWork && session.queuedMessageCount === 0;
|
|
33
|
+
const scope = new AsyncLocalStorage<Submission>();
|
|
34
|
+
let binding: Binding | undefined;
|
|
35
|
+
let runVoice: StagedVoice | undefined;
|
|
36
|
+
let approvedSignal: AbortSignal | undefined;
|
|
37
|
+
const clear = (token?: string) => {
|
|
38
|
+
if (token !== undefined && token !== binding?.token) return;
|
|
39
|
+
binding = undefined;
|
|
40
|
+
runVoice = undefined;
|
|
41
|
+
approvedSignal = undefined;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// Keep stock RPC's input path active even when no other extension handles it.
|
|
45
|
+
pi.on("input", () => {});
|
|
46
|
+
const emitInput = runner.emitInput;
|
|
47
|
+
const receive: typeof emitInput = async (text, images, source) => {
|
|
48
|
+
if (source !== "rpc" || !text.startsWith(wirePrefix)) return emitInput.call(runner, text, images, source);
|
|
49
|
+
const separator = text.indexOf("\n", wirePrefix.length);
|
|
50
|
+
if (separator === -1) throw new Error("Invalid owned reply voice input");
|
|
51
|
+
const original = text.slice(separator + 1);
|
|
52
|
+
const candidate = binding;
|
|
53
|
+
if (candidate?.phase !== "staged" || candidate.token !== text.slice(wirePrefix.length, separator)
|
|
54
|
+
|| digest(original) !== candidate.digest) throw new Error("Owned reply voice input did not match its staging");
|
|
55
|
+
// Strip the stock-only marker before other extensions see input; only a
|
|
56
|
+
// pass-through from the complete input hook may bind the RPC prompt.
|
|
57
|
+
const result = await emitInput.call(runner, original, images, source);
|
|
58
|
+
if (binding === candidate && !result.handled && (result.text ?? original) === original && idle()) {
|
|
59
|
+
const claimed = await claim(candidate.token).catch((error: unknown) => {
|
|
60
|
+
if (error instanceof Error) return false;
|
|
61
|
+
throw error;
|
|
62
|
+
});
|
|
63
|
+
if (binding === candidate) {
|
|
64
|
+
if (claimed) binding = { ...candidate, phase: "input" };
|
|
65
|
+
else clear();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return { ...result, text: result.text ?? original };
|
|
69
|
+
};
|
|
70
|
+
pi.on("before_agent_start", (event, ctx) => {
|
|
71
|
+
const submission = scope.getStore();
|
|
72
|
+
if (ctx.agent.kind === "main" && ctx.sessionManager === session.sessionManager && event.reason === "prompt"
|
|
73
|
+
&& submission?.admitted && submission.token === binding?.token && !runVoice) {
|
|
74
|
+
submission.prepared ??= digest(event.prompt);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const prompt = session.prompt;
|
|
79
|
+
// The private marker was consumed by the stock input carrier, not shown
|
|
80
|
+
// to a model. Observe its matching admission and actual new root input.
|
|
81
|
+
const boundPrompt: typeof prompt = (text, options) => {
|
|
82
|
+
const inherited = scope.getStore();
|
|
83
|
+
if (inherited?.kind === "local-command" && inherited.token === binding?.token && sameSession()
|
|
84
|
+
&& !session.isStreaming && !session.isRunActive
|
|
85
|
+
&& options?.expandPromptTemplates === false && options.throwOnDrop === true && options.streamingBehavior === "steer"
|
|
86
|
+
&& (options.attribution === undefined || options.attribution === "user")) {
|
|
87
|
+
// An extension command (such as a workflow alias) can handle the slash
|
|
88
|
+
// locally and submit its real user turn through pi.sendUserMessage.
|
|
89
|
+
// Use that SDK call's scoped admission, not the slash or rewritten text.
|
|
90
|
+
inherited.kind = "command-prompt";
|
|
91
|
+
return prompt.call(session, text, {
|
|
92
|
+
...options,
|
|
93
|
+
onPromptAdmitted: () => { inherited.admitted = session.isStreaming && !agent.state.isStreaming; },
|
|
94
|
+
}).finally(() => { if (runVoice?.token !== inherited.token) clear(inherited.token); });
|
|
95
|
+
}
|
|
96
|
+
const notify = options?.onPromptAdmitted;
|
|
97
|
+
if (binding?.phase !== "input" || !idle() || !options || typeof notify !== "function"
|
|
98
|
+
|| options.streamingBehavior !== undefined
|
|
99
|
+
|| !Object.hasOwn(options, "images") || !Object.hasOwn(options, "streamingBehavior") || Object.keys(options).length !== 3
|
|
100
|
+
|| digest(text) !== binding.digest) {
|
|
101
|
+
return scope.exit(() => prompt.call(session, text, options));
|
|
102
|
+
}
|
|
103
|
+
const { token } = binding;
|
|
104
|
+
binding = { ...binding, phase: "submitted" };
|
|
105
|
+
const submission: Submission = { token, kind: "prompt", admitted: false };
|
|
106
|
+
return scope.run(submission, () => prompt.call(session, text, {
|
|
107
|
+
...options,
|
|
108
|
+
onPromptAdmitted: () => {
|
|
109
|
+
// An idle SDK prompt routed to a local command fires the same
|
|
110
|
+
// callback before its handler, but has not claimed prompt setup.
|
|
111
|
+
submission.admitted = session.isStreaming && !agent.state.isStreaming;
|
|
112
|
+
if (!submission.admitted && !session.isStreaming) submission.kind = "local-command";
|
|
113
|
+
notify();
|
|
114
|
+
},
|
|
115
|
+
})).finally(() => {
|
|
116
|
+
if (submission.kind !== "command-prompt" && runVoice?.token !== token) clear(token);
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const dispatch = agent.streamFn;
|
|
121
|
+
const project: typeof dispatch = (model, input, options) => {
|
|
122
|
+
const voice = approvedSignal && !approvedSignal.aborted && session.isRunActive && sameSession()
|
|
123
|
+
&& !options?.signal?.aborted ? runVoice?.voice : undefined;
|
|
124
|
+
return dispatch(model, voice ? { ...input, systemPrompt: [...(input.systemPrompt ?? []), voice] } : input, options);
|
|
125
|
+
};
|
|
126
|
+
const unhook = agent.addBeforeModelCallHook((signal, context) => {
|
|
127
|
+
approvedSignal = undefined;
|
|
128
|
+
if (!sameSession() || !session.isRunActive || !signal || signal.aborted) return;
|
|
129
|
+
// A paused root run may resume in a fresh loop (and signal) to consume
|
|
130
|
+
// background work. The public run boundary, not the loop, owns the voice.
|
|
131
|
+
if (runVoice) { approvedSignal = signal; return; }
|
|
132
|
+
const submission = scope.getStore();
|
|
133
|
+
if (!submission?.admitted || !binding || submission.token !== binding.token) return;
|
|
134
|
+
// The first call's new input is in the loop context but has not yet
|
|
135
|
+
// emitted message_end. Use the current history after any pre-send rewrite.
|
|
136
|
+
const previousUser = agent.state.messages.findLast(isUserAuthoredMessage);
|
|
137
|
+
const previousIndex = previousUser ? context.messages.lastIndexOf(previousUser) : -1;
|
|
138
|
+
const firstUser = context.messages.find((message, index) => index > previousIndex && isUserAuthoredMessage(message));
|
|
139
|
+
if (firstUser?.role !== "user" || digest(messageText(firstUser)) !== submission.prepared) {
|
|
140
|
+
clear(submission.token);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
submission.prepared = undefined;
|
|
144
|
+
runVoice = binding;
|
|
145
|
+
approvedSignal = signal;
|
|
146
|
+
});
|
|
147
|
+
const unwatch = session.subscribeRunState(state => {
|
|
148
|
+
if (state === "idle" && runVoice) {
|
|
149
|
+
const { token } = runVoice;
|
|
150
|
+
clear(token);
|
|
151
|
+
retire(token);
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
runner.emitInput = receive;
|
|
155
|
+
session.prompt = boundPrompt;
|
|
156
|
+
agent.streamFn = project;
|
|
157
|
+
session.addDisposer(() => {
|
|
158
|
+
clear();
|
|
159
|
+
unwatch();
|
|
160
|
+
unhook();
|
|
161
|
+
if (runner.emitInput === receive) runner.emitInput = emitInput;
|
|
162
|
+
if (session.prompt === boundPrompt) session.prompt = prompt;
|
|
163
|
+
if (agent.streamFn === project) agent.streamFn = dispatch;
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
const available = () => sameSession() && session.extensionRunner === runner && runner.emitInput === receive
|
|
167
|
+
&& session.prompt === boundPrompt && agent.streamFn === project;
|
|
168
|
+
return {
|
|
169
|
+
available, clear,
|
|
170
|
+
stage(command: Frame): boolean {
|
|
171
|
+
const { token, message } = command;
|
|
172
|
+
if (!available() || binding || typeof token !== "string" || !token || typeof message !== "string") {
|
|
173
|
+
throw new Error("Native reply voice cannot be staged");
|
|
174
|
+
}
|
|
175
|
+
const voice = renderReplyVoice(command.voice);
|
|
176
|
+
if (!idle()) return false;
|
|
177
|
+
binding = { token, digest: digest(message), voice, phase: "staged" };
|
|
178
|
+
return true;
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
}
|
package/src/lane-extension.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { resolve } from "node:path";
|
|
|
4
4
|
import type { ToolCall, ToolResultMessage } from "@oh-my-pi/pi-ai";
|
|
5
5
|
import type { ExtensionAPI, ExtensionContext } from "@oh-my-pi/pi-coding-agent";
|
|
6
6
|
import { type Static, Type } from "@sinclair/typebox";
|
|
7
|
-
import { type LaneEvidence, type LaneReportEvent, parseLaneReportResult } from "./lane-report";
|
|
7
|
+
import { type LaneEvidence, type LaneReportEvent, type ScopeReviewReceipt, parseLaneReportResult } from "./lane-report";
|
|
8
8
|
import { registerResultAttach, RESULT_ATTACH_TOOL } from "./result-attachment";
|
|
9
9
|
import { registerDecisionAsk } from "./decision-tool";
|
|
10
10
|
|
|
@@ -29,6 +29,7 @@ const parameters = Type.Union([
|
|
|
29
29
|
{ additionalProperties: false }),
|
|
30
30
|
Type.Object({ status: Type.Literal("resolved"), summary, waiting, evidence: requiredEvidence },
|
|
31
31
|
{ additionalProperties: false }),
|
|
32
|
+
Type.Object({ status: Type.Literal("scope_review"), sourceId: nonempty }, { additionalProperties: false }),
|
|
32
33
|
]);
|
|
33
34
|
const coordinationTool = (name: string) => name === "lane_report" || name === RESULT_ATTACH_TOOL || name.startsWith("board_");
|
|
34
35
|
const record = (value: unknown): value is Record<string, unknown> =>
|
|
@@ -39,7 +40,12 @@ const keys = (value: Record<string, unknown>, names: string[]) =>
|
|
|
39
40
|
|
|
40
41
|
// Direct native/custom-tool dispatch can bypass model argument validation.
|
|
41
42
|
function validInput(input: unknown): input is Static<typeof parameters> {
|
|
42
|
-
if (!record(input)
|
|
43
|
+
if (!record(input)) return false;
|
|
44
|
+
if (input.status === "scope_review") {
|
|
45
|
+
return Object.hasOwn(input, "status") && Object.hasOwn(input, "sourceId") &&
|
|
46
|
+
keys(input, ["status", "sourceId"]) && text(input.sourceId);
|
|
47
|
+
}
|
|
48
|
+
if (!keys(input, ["status", "summary", "waiting", "evidence"]) ||
|
|
43
49
|
!text(input.summary) || input.summary.length > 4000 ||
|
|
44
50
|
!["progress", "waiting", "resolved"].includes(input.status as string)) return false;
|
|
45
51
|
if (input.evidence !== undefined && (!Array.isArray(input.evidence) || input.evidence.length > 32 ||
|
|
@@ -111,12 +117,12 @@ function toolEvidence(id: string, records: ReturnType<typeof toolRecords>): Lane
|
|
|
111
117
|
if (!call || !result || result.toolName !== call.name || result.isError !== false ||
|
|
112
118
|
coordinationTool(call.name) || (typeof call.arguments.path === "string" &&
|
|
113
119
|
/^xd:\/\/(?:lane_report|board_[a-z_]+)(?:[/?#]|$)/.test(call.arguments.path)) ||
|
|
114
|
-
parseLaneReportResult(result)) {
|
|
120
|
+
parseLaneReportResult(result) || (record(result.details) && result.details.type === "superagent-scope-review")) {
|
|
115
121
|
throw new Error("Lane tool evidence requires a completed successful native tool call, not report/board chatter");
|
|
116
122
|
}
|
|
117
123
|
// Native identity/time envelopes are not evidence of changed work.
|
|
118
|
-
const
|
|
119
|
-
return { kind: "tool", ref: id, fingerprint: createHash("sha256").update(JSON.stringify(
|
|
124
|
+
const resultRecord = { toolName: result.toolName, content: result.content, details: result.details, isError: result.isError };
|
|
125
|
+
return { kind: "tool", ref: id, fingerprint: createHash("sha256").update(JSON.stringify(resultRecord)).digest("hex") };
|
|
120
126
|
}
|
|
121
127
|
|
|
122
128
|
/** A worker role entrypoint, never the head's manager or messenger client. */
|
|
@@ -126,10 +132,12 @@ export default function laneExtension(pi: ExtensionAPI): void {
|
|
|
126
132
|
registerResultAttach(pi);
|
|
127
133
|
let approvalSessionId: string | undefined;
|
|
128
134
|
const pendingApprovals = new Set<string>();
|
|
135
|
+
const scopeApprovals = new Map<string, "requested" | "approved" | "unverified">();
|
|
129
136
|
const approvals = (ctx: ExtensionContext) => {
|
|
130
137
|
const sessionId = ctx.sessionManager.getSessionId();
|
|
131
138
|
if (approvalSessionId !== sessionId) {
|
|
132
139
|
pendingApprovals.clear();
|
|
140
|
+
scopeApprovals.clear();
|
|
133
141
|
approvalSessionId = sessionId;
|
|
134
142
|
}
|
|
135
143
|
return pendingApprovals;
|
|
@@ -154,12 +162,22 @@ export default function laneExtension(pi: ExtensionAPI): void {
|
|
|
154
162
|
pi.on("tool_approval_requested", (event, ctx) => {
|
|
155
163
|
if (ctx.agent.kind === "main" && event.sessionId === ctx.sessionManager.getSessionId()) {
|
|
156
164
|
approvals(ctx).add(event.toolCallId);
|
|
165
|
+
if (event.toolName === "lane_report")
|
|
166
|
+
scopeApprovals.set(event.toolCallId, scopeApprovals.has(event.toolCallId) ? "unverified" : "requested");
|
|
157
167
|
}
|
|
158
168
|
});
|
|
159
169
|
pi.on("tool_approval_resolved", (event, ctx) => {
|
|
160
|
-
if (event.sessionId
|
|
170
|
+
if (event.sessionId !== ctx.sessionManager.getSessionId()) return;
|
|
171
|
+
approvals(ctx).delete(event.toolCallId);
|
|
172
|
+
if (ctx.agent.kind === "main" && event.toolName === "lane_report")
|
|
173
|
+
scopeApprovals.set(event.toolCallId,
|
|
174
|
+
event.approved && scopeApprovals.get(event.toolCallId) === "requested" ? "approved" : "unverified");
|
|
175
|
+
});
|
|
176
|
+
pi.on("agent_end", (_event, ctx) => { if (ctx.agent.kind === "main") scopeApprovals.clear(); });
|
|
177
|
+
pi.on("session_shutdown", () => {
|
|
178
|
+
pendingApprovals.clear();
|
|
179
|
+
scopeApprovals.clear();
|
|
161
180
|
});
|
|
162
|
-
pi.on("session_shutdown", () => { pendingApprovals.clear(); });
|
|
163
181
|
pi.on("before_agent_start", async (event, ctx) => {
|
|
164
182
|
if (ctx.agent.kind !== "main") return;
|
|
165
183
|
return { systemPrompt: [
|
|
@@ -173,11 +191,31 @@ export default function laneExtension(pi: ExtensionAPI): void {
|
|
|
173
191
|
description: "Record an evidence-backed progress, waiting, or resolved observation in this lane's native tool journal. " +
|
|
174
192
|
"Progress/resolved require selected real file paths or completed successful native toolCallIds; hashes are computed here. " +
|
|
175
193
|
"Waiting/resolved name the exact tool/approval/job ID or a dependency label. Native tool/approval/job waiting IDs must be observable now. " +
|
|
194
|
+
"For a standalone original owner message in the active bound topic that appears to supersede the existing assignment, " +
|
|
195
|
+
"call lane_report directly with status scope_review and its Original source ID, never via eval, bash, or write. " +
|
|
196
|
+
"This only requests HEAD review; it does not grant permission. " +
|
|
176
197
|
"Reports do not send messages, prove acceptance, dispatch, resume, or change execution authority. Board/report chatter is not evidence.",
|
|
177
198
|
parameters,
|
|
178
|
-
async execute(id, params,
|
|
199
|
+
async execute(id, params, signal, _onUpdate, ctx) {
|
|
179
200
|
if (ctx.agent.kind !== "main") throw new Error("Lane reporting is restricted to the root lane session");
|
|
180
201
|
if (!validInput(params)) throw new Error("Invalid lane report parameters");
|
|
202
|
+
approvals(ctx);
|
|
203
|
+
const nativeApproval = scopeApprovals.get(id);
|
|
204
|
+
scopeApprovals.delete(id);
|
|
205
|
+
if (params.status === "scope_review") {
|
|
206
|
+
signal?.throwIfAborted();
|
|
207
|
+
const sessionFile = ctx.sessionManager.getSessionFile();
|
|
208
|
+
if (!sessionFile) throw new Error("Lane scope review requires a native session file");
|
|
209
|
+
const receipt: ScopeReviewReceipt = {
|
|
210
|
+
type: "superagent-scope-review", sourceId: params.sourceId,
|
|
211
|
+
sessionId: ctx.sessionManager.getSessionId(), sessionFile, toolCallId: id,
|
|
212
|
+
};
|
|
213
|
+
// Only a matched direct native start/end can request review. Do not append a custom entry.
|
|
214
|
+
return {
|
|
215
|
+
content: [{ type: "text", text: "Emitted a scope-review signal. HEAD admission depends on controller verification and successful settlement; the assignment has not changed." }],
|
|
216
|
+
details: nativeApproval === undefined ? receipt : { ...receipt, nativeApproval },
|
|
217
|
+
};
|
|
218
|
+
}
|
|
181
219
|
const target = params.status === "waiting" ? params.waiting : undefined;
|
|
182
220
|
if (target?.kind === "approval" && !approvals(ctx).has(target.id)) {
|
|
183
221
|
throw new Error("Lane approval wait requires an observed pending native tool approval");
|
package/src/lane-report.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isAbsolute, normalize } from "node:path";
|
|
2
|
+
import { isDeepStrictEqual } from "node:util";
|
|
2
3
|
|
|
3
4
|
export type LaneWaitTarget =
|
|
4
5
|
| { kind: "tool" | "approval" | "job"; id: string; target: string }
|
|
@@ -24,6 +25,27 @@ export interface LaneReportEvent {
|
|
|
24
25
|
report: LaneReport;
|
|
25
26
|
}
|
|
26
27
|
|
|
28
|
+
/** Evidence of a tool execution only; it does not authorize a scope change. */
|
|
29
|
+
export type ScopeReviewReceipt = {
|
|
30
|
+
readonly type: "superagent-scope-review";
|
|
31
|
+
readonly sourceId: string;
|
|
32
|
+
readonly sessionId: string;
|
|
33
|
+
readonly sessionFile: string;
|
|
34
|
+
readonly toolCallId: string;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/** Stock OMP select wire for this tool. A positive answer describes this call
|
|
38
|
+
* only; the native Host, not the controller, handles any session-wide choice. */
|
|
39
|
+
export function scopeReviewApproval(request: Record<string, unknown>, response?: { value?: string }): boolean {
|
|
40
|
+
if (request.method !== "select" || request.secret === true) return false;
|
|
41
|
+
const options = request.options;
|
|
42
|
+
const session = "Approve lane_report for this session";
|
|
43
|
+
if (!isDeepStrictEqual(options, ["Approve", "Deny"]) && !isDeepStrictEqual(options, ["Approve", session, "Deny"])) return false;
|
|
44
|
+
if (!response) return true;
|
|
45
|
+
return isDeepStrictEqual(response, { value: "Approve" })
|
|
46
|
+
|| Array.isArray(options) && options.includes(session) && isDeepStrictEqual(response, { value: session });
|
|
47
|
+
}
|
|
48
|
+
|
|
27
49
|
export function laneWaitKey(waiting: LaneWaitTarget): string {
|
|
28
50
|
return JSON.stringify([waiting.kind, waiting.kind === "dependency" ? waiting.target : waiting.id]);
|
|
29
51
|
}
|
package/src/message-order.ts
CHANGED
|
@@ -2,7 +2,8 @@ import type { Platform } from "./contracts";
|
|
|
2
2
|
|
|
3
3
|
/** Platform message order only; event/edit IDs and local arrival times are not clocks. */
|
|
4
4
|
export function compareMessageIds(platform: Platform, left: string, right: string): -1 | 0 | 1 | null {
|
|
5
|
-
|
|
5
|
+
// Kakao log IDs are numeric and increase within a chat.
|
|
6
|
+
if (platform === "discord" || platform === "telegram" || platform === "kakao") {
|
|
6
7
|
if (!/^\d+$/.test(left) || !/^\d+$/.test(right)) return null;
|
|
7
8
|
const a = BigInt(left);
|
|
8
9
|
const b = BigInt(right);
|