@codetreker/daynight 0.25.2 → 0.26.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/README.md +116 -8
- package/config.example.yml +3 -0
- package/dist/api/client.js +2 -2
- package/dist/api/client.js.map +1 -1
- package/dist/api/parse.js +14 -2
- package/dist/api/parse.js.map +1 -1
- package/dist/api/types.d.ts +4 -1
- package/dist/api/worker-mode.d.ts +6 -0
- package/dist/api/worker-mode.js +14 -0
- package/dist/api/worker-mode.js.map +1 -0
- package/dist/cli/commands.js +2 -0
- package/dist/cli/commands.js.map +1 -1
- package/dist/commands/controller/command-controls.d.ts +4 -0
- package/dist/commands/controller/command-controls.js +33 -0
- package/dist/commands/controller/command-controls.js.map +1 -0
- package/dist/commands/controller/definition.d.ts +3 -0
- package/dist/commands/controller/definition.js +22 -0
- package/dist/commands/controller/definition.js.map +1 -0
- package/dist/commands/controller/independent.d.ts +3 -0
- package/dist/commands/controller/independent.js +344 -0
- package/dist/commands/controller/independent.js.map +1 -0
- package/dist/commands/controller/index.d.ts +12 -0
- package/dist/commands/controller/index.js +73 -0
- package/dist/commands/controller/index.js.map +1 -0
- package/dist/commands/controller/launch-ticket.d.ts +49 -0
- package/dist/commands/controller/launch-ticket.js +99 -0
- package/dist/commands/controller/launch-ticket.js.map +1 -0
- package/dist/commands/controller/lifecycle-store.d.ts +84 -0
- package/dist/commands/controller/lifecycle-store.js +278 -0
- package/dist/commands/controller/lifecycle-store.js.map +1 -0
- package/dist/commands/controller/local-client.d.ts +44 -0
- package/dist/commands/controller/local-client.js +75 -0
- package/dist/commands/controller/local-client.js.map +1 -0
- package/dist/commands/controller/local-content.d.ts +23 -0
- package/dist/commands/controller/local-content.js +103 -0
- package/dist/commands/controller/local-content.js.map +1 -0
- package/dist/commands/controller/process-proof.d.ts +13 -0
- package/dist/commands/controller/process-proof.js +121 -0
- package/dist/commands/controller/process-proof.js.map +1 -0
- package/dist/commands/controller/providers/claude.d.ts +2 -0
- package/dist/commands/controller/providers/claude.js +470 -0
- package/dist/commands/controller/providers/claude.js.map +1 -0
- package/dist/commands/controller/providers/codex.d.ts +2 -0
- package/dist/commands/controller/providers/codex.js +254 -0
- package/dist/commands/controller/providers/codex.js.map +1 -0
- package/dist/commands/controller/providers/controls-claude.d.ts +26 -0
- package/dist/commands/controller/providers/controls-claude.js +138 -0
- package/dist/commands/controller/providers/controls-claude.js.map +1 -0
- package/dist/commands/controller/providers/controls-codex.d.ts +38 -0
- package/dist/commands/controller/providers/controls-codex.js +199 -0
- package/dist/commands/controller/providers/controls-codex.js.map +1 -0
- package/dist/commands/controller/providers/controls-copilot.d.ts +20 -0
- package/dist/commands/controller/providers/controls-copilot.js +143 -0
- package/dist/commands/controller/providers/controls-copilot.js.map +1 -0
- package/dist/commands/controller/providers/controls.d.ts +21 -0
- package/dist/commands/controller/providers/controls.js +53 -0
- package/dist/commands/controller/providers/controls.js.map +1 -0
- package/dist/commands/controller/providers/copilot-interactions.d.ts +47 -0
- package/dist/commands/controller/providers/copilot-interactions.js +295 -0
- package/dist/commands/controller/providers/copilot-interactions.js.map +1 -0
- package/dist/commands/controller/providers/copilot-projection.d.ts +11 -0
- package/dist/commands/controller/providers/copilot-projection.js +93 -0
- package/dist/commands/controller/providers/copilot-projection.js.map +1 -0
- package/dist/commands/controller/providers/copilot-runtime.d.ts +9 -0
- package/dist/commands/controller/providers/copilot-runtime.js +127 -0
- package/dist/commands/controller/providers/copilot-runtime.js.map +1 -0
- package/dist/commands/controller/providers/copilot.d.ts +2 -0
- package/dist/commands/controller/providers/copilot.js +309 -0
- package/dist/commands/controller/providers/copilot.js.map +1 -0
- package/dist/commands/controller/providers/interactions.d.ts +3 -0
- package/dist/commands/controller/providers/interactions.js +79 -0
- package/dist/commands/controller/providers/interactions.js.map +1 -0
- package/dist/commands/controller/providers/native-rpc.d.ts +28 -0
- package/dist/commands/controller/providers/native-rpc.js +85 -0
- package/dist/commands/controller/providers/native-rpc.js.map +1 -0
- package/dist/commands/controller/providers/projection.d.ts +23 -0
- package/dist/commands/controller/providers/projection.js +99 -0
- package/dist/commands/controller/providers/projection.js.map +1 -0
- package/dist/commands/controller/providers/turns.d.ts +7 -0
- package/dist/commands/controller/providers/turns.js +21 -0
- package/dist/commands/controller/providers/turns.js.map +1 -0
- package/dist/commands/controller/providers/types.d.ts +44 -0
- package/dist/commands/controller/providers/types.js +2 -0
- package/dist/commands/controller/providers/types.js.map +1 -0
- package/dist/commands/controller/recovery.d.ts +6 -0
- package/dist/commands/controller/recovery.js +22 -0
- package/dist/commands/controller/recovery.js.map +1 -0
- package/dist/commands/controller/relay.d.ts +18 -0
- package/dist/commands/controller/relay.js +299 -0
- package/dist/commands/controller/relay.js.map +1 -0
- package/dist/commands/controller/resume.d.ts +18 -0
- package/dist/commands/controller/resume.js +193 -0
- package/dist/commands/controller/resume.js.map +1 -0
- package/dist/commands/controller/runtime.d.ts +5 -0
- package/dist/commands/controller/runtime.js +455 -0
- package/dist/commands/controller/runtime.js.map +1 -0
- package/dist/commands/controller/windows-job.d.ts +3 -0
- package/dist/commands/controller/windows-job.js +59 -0
- package/dist/commands/controller/windows-job.js.map +1 -0
- package/dist/commands/controller/wire-display.d.ts +5 -0
- package/dist/commands/controller/wire-display.js +11 -0
- package/dist/commands/controller/wire-display.js.map +1 -0
- package/dist/commands/skill/skills/using-daynight/SKILL.md +24 -20
- package/dist/commands/skill/skills/using-daynight/references/autopilot-managed-task.md +16 -10
- package/dist/commands/skill/skills/using-daynight/references/create-task.md +40 -39
- package/dist/commands/skill/skills/using-daynight/references/goal.md +40 -29
- package/dist/commands/skill/skills/using-daynight/references/handbook.md +4 -3
- package/dist/commands/skill/skills/using-daynight/references/handoff.md +3 -0
- package/dist/commands/skill/skills/using-daynight/references/run-task.md +3 -3
- package/dist/commands/skill/skills/using-daynight/references/task-content.md +96 -51
- package/dist/commands/skill/skills/using-daynight/references/task-execution.md +28 -22
- package/dist/commands/worker/backend.d.ts +7 -0
- package/dist/commands/worker/backend.js +7 -0
- package/dist/commands/worker/backend.js.map +1 -0
- package/dist/commands/worker/backends/grant-renewal.d.ts +13 -0
- package/dist/commands/worker/backends/grant-renewal.js +42 -0
- package/dist/commands/worker/backends/grant-renewal.js.map +1 -0
- package/dist/commands/worker/backends/session-api.d.ts +66 -0
- package/dist/commands/worker/backends/session-api.js +84 -0
- package/dist/commands/worker/backends/session-api.js.map +1 -0
- package/dist/commands/worker/backends/web-process.d.ts +79 -0
- package/dist/commands/worker/backends/web-process.js +156 -0
- package/dist/commands/worker/backends/web-process.js.map +1 -0
- package/dist/commands/worker/backends/web-store.d.ts +49 -0
- package/dist/commands/worker/backends/web-store.js +323 -0
- package/dist/commands/worker/backends/web-store.js.map +1 -0
- package/dist/commands/worker/backends/web-types.d.ts +83 -0
- package/dist/commands/worker/backends/web-types.js +3 -0
- package/dist/commands/worker/backends/web-types.js.map +1 -0
- package/dist/commands/worker/backends/web.d.ts +26 -0
- package/dist/commands/worker/backends/web.js +178 -0
- package/dist/commands/worker/backends/web.js.map +1 -0
- package/dist/commands/worker/config.js +12 -5
- package/dist/commands/worker/config.js.map +1 -1
- package/dist/commands/worker/control.d.ts +2 -0
- package/dist/commands/worker/control.js +11 -4
- package/dist/commands/worker/control.js.map +1 -1
- package/dist/commands/worker/coordinator.d.ts +7 -0
- package/dist/commands/worker/coordinator.js +138 -19
- package/dist/commands/worker/coordinator.js.map +1 -1
- package/dist/commands/worker/herdr/agents.js +11 -8
- package/dist/commands/worker/herdr/agents.js.map +1 -1
- package/dist/commands/worker/herdr/arguments.js +10 -5
- package/dist/commands/worker/herdr/arguments.js.map +1 -1
- package/dist/commands/worker/herdr/claude-input.d.ts +2 -0
- package/dist/commands/worker/herdr/claude-input.js +20 -0
- package/dist/commands/worker/herdr/claude-input.js.map +1 -0
- package/dist/commands/worker/herdr/instance.js +1 -1
- package/dist/commands/worker/herdr/instance.js.map +1 -1
- package/dist/commands/worker/herdr/preflight.d.ts +1 -1
- package/dist/commands/worker/herdr/preflight.js +31 -10
- package/dist/commands/worker/herdr/preflight.js.map +1 -1
- package/dist/commands/worker/herdr.js +5 -1
- package/dist/commands/worker/herdr.js.map +1 -1
- package/dist/commands/worker/prompts.js +5 -1
- package/dist/commands/worker/prompts.js.map +1 -1
- package/dist/commands/worker/repositories.js +2 -2
- package/dist/commands/worker/repositories.js.map +1 -1
- package/dist/commands/worker/runtime.js +62 -10
- package/dist/commands/worker/runtime.js.map +1 -1
- package/dist/commands/worker/setup-environment.d.ts +2 -1
- package/dist/commands/worker/setup-environment.js +10 -4
- package/dist/commands/worker/setup-environment.js.map +1 -1
- package/dist/commands/worker/setup.js +5 -5
- package/dist/commands/worker/setup.js.map +1 -1
- package/dist/commands/worker/store.d.ts +2 -1
- package/dist/commands/worker/store.js +19 -9
- package/dist/commands/worker/store.js.map +1 -1
- package/dist/commands/worker/types.d.ts +4 -1
- package/dist/commands/worker/worktrees.js +9 -6
- package/dist/commands/worker/worktrees.js.map +1 -1
- package/dist/session/controller-protocol.d.ts +245 -0
- package/dist/session/controller-protocol.js +218 -0
- package/dist/session/controller-protocol.js.map +1 -0
- package/dist/session/controls.d.ts +28 -0
- package/dist/session/controls.js +37 -0
- package/dist/session/controls.js.map +1 -0
- package/dist/session/protocol.d.ts +290 -0
- package/dist/session/protocol.js +307 -0
- package/dist/session/protocol.js.map +1 -0
- package/package.json +7 -2
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { constants } from "node:fs";
|
|
3
|
+
import { open, opendir } from "node:fs/promises";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { ProviderControls, controlDeadline, controlError, uniqueOptions, sameControlValue } from "./controls.js";
|
|
6
|
+
import { record, string, NativeRpcError } from "./native-rpc.js";
|
|
7
|
+
export class CodexControls {
|
|
8
|
+
rpc;
|
|
9
|
+
session;
|
|
10
|
+
turn;
|
|
11
|
+
cwd;
|
|
12
|
+
home;
|
|
13
|
+
confirmed;
|
|
14
|
+
store;
|
|
15
|
+
native = {};
|
|
16
|
+
sandboxPolicies = new Map();
|
|
17
|
+
models = [];
|
|
18
|
+
requirements = null;
|
|
19
|
+
commands = new Map();
|
|
20
|
+
pending = new Map();
|
|
21
|
+
closed = false;
|
|
22
|
+
constructor(rpc, session, turn, cwd, home, changed, confirmed, revisionFloor = "0") {
|
|
23
|
+
this.rpc = rpc;
|
|
24
|
+
this.session = session;
|
|
25
|
+
this.turn = turn;
|
|
26
|
+
this.cwd = cwd;
|
|
27
|
+
this.home = home;
|
|
28
|
+
this.confirmed = confirmed;
|
|
29
|
+
this.store = new ProviderControls(changed, revisionFloor);
|
|
30
|
+
}
|
|
31
|
+
seed(value) { const raw = record(value); this.observe({ ...raw, ...(raw.sandbox ? { sandboxPolicy: raw.sandbox } : {}), ...(raw.reasoningEffort ? { effort: raw.reasoningEffort } : {}) }); }
|
|
32
|
+
observe(value) {
|
|
33
|
+
this.native = { ...this.native, ...record(value) };
|
|
34
|
+
const sandbox = record(this.native.sandboxPolicy);
|
|
35
|
+
if (typeof sandbox.type === "string")
|
|
36
|
+
this.sandboxPolicies.set(sandbox.type, structuredClone(sandbox));
|
|
37
|
+
this.describe();
|
|
38
|
+
for (const [id, pending] of this.pending)
|
|
39
|
+
if (Object.entries(pending.patch).every(([key, value]) => sameControlValue(this.native[key], value))) {
|
|
40
|
+
this.pending.delete(id);
|
|
41
|
+
pending.resolve();
|
|
42
|
+
this.confirmed?.(id);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
describe(error = this.store.value.settingsError) {
|
|
46
|
+
const model = string(this.native.model) || null, selected = this.models.find(item => item.model === model);
|
|
47
|
+
const efforts = Array.isArray(selected?.supportedReasoningEfforts) ? selected.supportedReasoningEfforts.map(item => string(record(item).reasoningEffort)).filter(Boolean) : [];
|
|
48
|
+
const settings = [{ id: "model", category: "model", label: "Model", value: model, options: uniqueOptions(this.models.map(item => ({ value: string(item.model), label: string(item.displayName) || string(item.model) }))), mutable: this.models.length > 0, scope: "session", description: "Changes subsequent native steps when supported, and future turns." }];
|
|
49
|
+
if (efforts.length)
|
|
50
|
+
settings.push({ id: "effort", category: "reasoning", label: "Reasoning effort", value: string(this.native.effort) || string(selected?.defaultReasoningEffort) || null, options: uniqueOptions(efforts.map(value => ({ value, label: value }))), mutable: true, scope: "session", description: "The native model defines supported effort levels." });
|
|
51
|
+
const approval = this.native.approvalPolicy, sandbox = record(this.native.sandboxPolicy);
|
|
52
|
+
const allowed = (key, value) => !Array.isArray(this.requirements?.[key]) || this.requirements[key].includes(value);
|
|
53
|
+
settings.push({ id: "approval", category: "permission", label: "Approval policy", value: typeof approval === "string" ? approval : null, options: [{ value: "untrusted", label: "Untrusted" }, { value: "on-request", label: "On request" }, { value: "never", label: "Never ask" }].filter(item => allowed("allowedApprovalPolicies", item.value)), mutable: this.requirements !== null && typeof approval === "string", scope: "next_turn", description: "Approval policy for subsequent turns. Sandbox restrictions remain independent." });
|
|
54
|
+
const modes = { readOnly: "read-only", workspaceWrite: "workspace-write", dangerFullAccess: "danger-full-access" };
|
|
55
|
+
settings.push({ id: "sandbox", category: "permission", label: "Sandbox", value: string(sandbox.type) || null, options: [{ value: "readOnly", label: "Read only" }, { value: "workspaceWrite", label: "Workspace write" }, { value: "dangerFullAccess", label: "Full access" }].filter(item => allowed("allowedSandboxModes", modes[item.value])), mutable: this.requirements !== null && !!sandbox.type, scope: "next_turn", description: "Native sandbox for subsequent turns. Full access removes filesystem and network restrictions." });
|
|
56
|
+
this.store.update({ settings, settingsError: error });
|
|
57
|
+
}
|
|
58
|
+
async refresh() {
|
|
59
|
+
try {
|
|
60
|
+
const models = [], cursors = new Set();
|
|
61
|
+
let cursor;
|
|
62
|
+
do {
|
|
63
|
+
const result = record(await controlDeadline(this.rpc.request("model/list", { ...(cursor ? { cursor } : {}) }), "Codex model discovery"));
|
|
64
|
+
if (!Array.isArray(result.data))
|
|
65
|
+
throw new Error("Invalid native model catalog.");
|
|
66
|
+
models.push(...result.data.map(record).filter(item => item.hidden !== true && string(item.model)));
|
|
67
|
+
cursor = string(result.nextCursor) || undefined;
|
|
68
|
+
if (models.length > 500 || cursor && cursors.has(cursor))
|
|
69
|
+
throw new Error("Native model catalog exceeded its bound.");
|
|
70
|
+
if (cursor)
|
|
71
|
+
cursors.add(cursor);
|
|
72
|
+
} while (cursor);
|
|
73
|
+
this.models = models;
|
|
74
|
+
try {
|
|
75
|
+
const result = record(await this.rpc.request("configRequirements/read", {}));
|
|
76
|
+
this.requirements = result.requirements === null ? {} : result.requirements && typeof result.requirements === "object" && !Array.isArray(result.requirements) ? record(result.requirements) : null;
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
this.requirements = null;
|
|
80
|
+
}
|
|
81
|
+
this.describe(null);
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
this.models = [];
|
|
85
|
+
this.requirements = null;
|
|
86
|
+
this.describe(controlError(error));
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
const next = new Map([["compact", { kind: "compact" }]]);
|
|
90
|
+
const commands = [{ id: "compact", name: "compact", description: "Compact the current Codex thread", argumentHint: null, available: true }];
|
|
91
|
+
const result = record(await controlDeadline(this.rpc.request("skills/list", { cwds: [this.cwd], forceReload: true }), "Codex command discovery"));
|
|
92
|
+
if (!Array.isArray(result.data))
|
|
93
|
+
throw new Error("Invalid native skill directory.");
|
|
94
|
+
for (const group of result.data.map(record))
|
|
95
|
+
for (const raw of Array.isArray(group.skills) ? group.skills : []) {
|
|
96
|
+
const skill = record(raw), name = string(skill.name), path = string(skill.path);
|
|
97
|
+
if (group.cwd !== this.cwd || skill.enabled !== true || !name || !path || next.size >= 450)
|
|
98
|
+
continue;
|
|
99
|
+
const id = `skill:${createHash("sha256").update(path).digest("hex")}`;
|
|
100
|
+
next.set(id, { kind: "skill", name, path });
|
|
101
|
+
commands.push({ id, name, description: (string(skill.description) || "Codex skill").slice(0, 1000), argumentHint: "Instructions for this skill", available: true });
|
|
102
|
+
}
|
|
103
|
+
let directory;
|
|
104
|
+
try {
|
|
105
|
+
directory = await opendir(join(this.home, "prompts"));
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
if (error.code !== "ENOENT")
|
|
109
|
+
throw error;
|
|
110
|
+
}
|
|
111
|
+
if (directory) {
|
|
112
|
+
let count = 0;
|
|
113
|
+
for await (const item of directory) {
|
|
114
|
+
if (++count > 1000)
|
|
115
|
+
throw new Error("Native prompt directory exceeded its bound.");
|
|
116
|
+
if (!item.isFile() || !/^[a-zA-Z0-9][a-zA-Z0-9_.:-]{0,127}\.md$/.test(item.name) || next.size >= 500)
|
|
117
|
+
continue;
|
|
118
|
+
const file = await open(join(this.home, "prompts", item.name), constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
119
|
+
try {
|
|
120
|
+
const stat = await file.stat();
|
|
121
|
+
if (!stat.isFile() || stat.size > 262144)
|
|
122
|
+
continue;
|
|
123
|
+
const text = await file.readFile("utf8");
|
|
124
|
+
if (Buffer.byteLength(text) > 262144)
|
|
125
|
+
continue;
|
|
126
|
+
const body = text.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n/, ""), name = item.name.slice(0, -3), id = `prompt:${name}`;
|
|
127
|
+
next.set(id, { kind: "prompt", body });
|
|
128
|
+
commands.push({ id, name: `prompts:${name}`, description: "Custom Codex prompt", argumentHint: "Raw arguments ($ARGUMENTS only)", available: true });
|
|
129
|
+
}
|
|
130
|
+
finally {
|
|
131
|
+
await file.close();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
this.commands = next;
|
|
136
|
+
this.store.update({ commands, commandsError: null });
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
this.commands.clear();
|
|
140
|
+
this.store.update({ commands: [], commandsError: controlError(error) });
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
async set(id, value, operationId, revision) {
|
|
144
|
+
this.store.setting(id, value, revision);
|
|
145
|
+
if (this.closed)
|
|
146
|
+
throw new Error("Native session closed.");
|
|
147
|
+
const patch = id === "model" ? { model: value } : id === "effort" ? { effort: value } : id === "approval" ? { approvalPolicy: value } : { sandboxPolicy: this.sandbox(value) };
|
|
148
|
+
if (id === "model") {
|
|
149
|
+
const selected = this.models.find(item => item.model === value), efforts = Array.isArray(selected?.supportedReasoningEfforts) ? selected.supportedReasoningEfforts.map(item => string(record(item).reasoningEffort)) : [];
|
|
150
|
+
const effort = string(this.native.effort);
|
|
151
|
+
if (!efforts.includes(effort) && selected?.defaultReasoningEffort)
|
|
152
|
+
patch.effort = selected.defaultReasoningEffort;
|
|
153
|
+
}
|
|
154
|
+
const turnId = this.turn();
|
|
155
|
+
let liveApplied = false;
|
|
156
|
+
if (turnId && ["model", "effort"].includes(id)) {
|
|
157
|
+
const result = record(await this.rpc.request("turn/settings/update", { threadId: this.session(), turnId, ...patch }));
|
|
158
|
+
if (result.status !== "applied")
|
|
159
|
+
throw new NativeRpcError(-32602, "Native live model switching is unavailable. Wait for the current turn to finish.");
|
|
160
|
+
liveApplied = true;
|
|
161
|
+
}
|
|
162
|
+
let resolve, reject;
|
|
163
|
+
const confirmation = new Promise((done, fail) => { resolve = done; reject = fail; });
|
|
164
|
+
void confirmation.catch(() => { });
|
|
165
|
+
this.pending.set(operationId, { patch, resolve, reject });
|
|
166
|
+
try {
|
|
167
|
+
await this.rpc.request("thread/settings/update", { threadId: this.session(), ...patch });
|
|
168
|
+
}
|
|
169
|
+
catch (error) {
|
|
170
|
+
if (error instanceof NativeRpcError)
|
|
171
|
+
this.pending.delete(operationId);
|
|
172
|
+
if (liveApplied) {
|
|
173
|
+
const message = `Codex applied this setting to the current turn, but future-turn settings are unconfirmed: ${controlError(error)}`;
|
|
174
|
+
this.store.update({ settingsError: message });
|
|
175
|
+
throw new Error(message);
|
|
176
|
+
}
|
|
177
|
+
throw error;
|
|
178
|
+
}
|
|
179
|
+
await controlDeadline(confirmation, "Codex setting confirmation");
|
|
180
|
+
}
|
|
181
|
+
sandbox(type) {
|
|
182
|
+
const saved = this.sandboxPolicies.get(type);
|
|
183
|
+
if (saved)
|
|
184
|
+
return saved;
|
|
185
|
+
const old = record(this.native.sandboxPolicy);
|
|
186
|
+
if (old.type === type)
|
|
187
|
+
return old;
|
|
188
|
+
if (type === "dangerFullAccess")
|
|
189
|
+
return { type };
|
|
190
|
+
if (type === "readOnly")
|
|
191
|
+
return { type, networkAccess: false };
|
|
192
|
+
return { type, writableRoots: [], networkAccess: false, excludeTmpdirEnvVar: false, excludeSlashTmp: false };
|
|
193
|
+
}
|
|
194
|
+
command(id, revision) { this.store.command(id, revision); const command = this.commands.get(id); if (!command)
|
|
195
|
+
throw new NativeRpcError(-32602, "Command is no longer available."); return command; }
|
|
196
|
+
close() { this.closed = true; for (const item of this.pending.values())
|
|
197
|
+
item.reject(new Error("Native Codex closed before setting confirmation.")); this.pending.clear(); }
|
|
198
|
+
}
|
|
199
|
+
//# sourceMappingURL=controls-codex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controls-codex.js","sourceRoot":"","sources":["../../../../src/commands/controller/providers/controls-codex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAuB,MAAM,eAAe,CAAC;AACtI,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,EAAkB,MAAM,iBAAiB,CAAC;AAEjF,MAAM,OAAO,aAAa;IASK,GAAG;IAA8B,OAAO;IAAiC,IAAI;IAAwC,GAAG;IAA2B,IAAI;IAAgD,SAAS;IARpO,KAAK,CAAm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AC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;QAAE,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;CAC5K"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { CopilotSession } from "@github/copilot-sdk";
|
|
2
|
+
import { ProviderControls } from "./controls.js";
|
|
3
|
+
export declare class CopilotControls {
|
|
4
|
+
private readonly native;
|
|
5
|
+
private readonly confirmed?;
|
|
6
|
+
private readonly skillDiscoveryError;
|
|
7
|
+
readonly store: ProviderControls;
|
|
8
|
+
private toolApproval;
|
|
9
|
+
private pending;
|
|
10
|
+
private pollTimer;
|
|
11
|
+
private polling;
|
|
12
|
+
private closed;
|
|
13
|
+
constructor(native: CopilotSession, changed: () => void, confirmed?: ((operationId: string) => void) | undefined, revisionFloor?: string, skillDiscoveryError?: string | null);
|
|
14
|
+
private permissions;
|
|
15
|
+
initialize(resume: boolean, unattended?: boolean): Promise<void>;
|
|
16
|
+
refresh(includeCommands?: boolean): Promise<void>;
|
|
17
|
+
set(id: string, value: string, operationId: string, revision: string): Promise<void>;
|
|
18
|
+
invoke(id: string, args: string, revision: string): ReturnType<CopilotSession["rpc"]["commands"]["invoke"]>;
|
|
19
|
+
close(): void;
|
|
20
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { ProviderControls, controlDeadline, controlError, uniqueOptions } from "./controls.js";
|
|
2
|
+
import { record, string, NativeRpcError } from "./native-rpc.js";
|
|
3
|
+
export class CopilotControls {
|
|
4
|
+
native;
|
|
5
|
+
confirmed;
|
|
6
|
+
skillDiscoveryError;
|
|
7
|
+
store;
|
|
8
|
+
toolApproval = null;
|
|
9
|
+
pending = new Map();
|
|
10
|
+
pollTimer;
|
|
11
|
+
polling = false;
|
|
12
|
+
closed = false;
|
|
13
|
+
constructor(native, changed, confirmed, revisionFloor = "0", skillDiscoveryError = null) {
|
|
14
|
+
this.native = native;
|
|
15
|
+
this.confirmed = confirmed;
|
|
16
|
+
this.skillDiscoveryError = skillDiscoveryError;
|
|
17
|
+
this.store = new ProviderControls(changed, revisionFloor);
|
|
18
|
+
}
|
|
19
|
+
permissions() { return { id: "tool_approval", category: "permission", label: "Tool approvals", value: this.toolApproval, mutable: typeof this.native.rpc.permissions.setApproveAll === "function", scope: "session", description: "Native tool approval policy. Existing grants, path and network permissions are independent.", options: [{ value: "ask", label: "Ask for approval" }, { value: "allow", label: "Allow tools" }] }; }
|
|
20
|
+
async initialize(resume, unattended = false) {
|
|
21
|
+
if (!resume && unattended) {
|
|
22
|
+
if (typeof this.native.rpc.permissions.configure !== "function")
|
|
23
|
+
throw new Error("Native Copilot cannot configure unattended full access.");
|
|
24
|
+
// SDK sessions have independent path and URL managers; runtime flags and
|
|
25
|
+
// setApproveAll alone do not authorize access outside the task worktree.
|
|
26
|
+
const result = await controlDeadline(this.native.rpc.permissions.configure({ approveAllToolPermissionRequests: true, approveAllReadPermissionRequests: true, paths: { unrestricted: true }, urls: { unrestricted: true } }), "Copilot full access initialization");
|
|
27
|
+
if (!result.success)
|
|
28
|
+
throw new Error("Copilot did not confirm unattended full access.");
|
|
29
|
+
this.toolApproval = "allow";
|
|
30
|
+
}
|
|
31
|
+
else if (!resume && typeof this.native.rpc.permissions.setApproveAll === "function") {
|
|
32
|
+
try {
|
|
33
|
+
const result = await controlDeadline(this.native.rpc.permissions.setApproveAll({ enabled: false }), "Copilot permission initialization");
|
|
34
|
+
if (!result.success)
|
|
35
|
+
throw new Error("Copilot did not confirm default tool permissions.");
|
|
36
|
+
this.toolApproval = "ask";
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
this.store.update({ settingsError: controlError(error) });
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (!resume && unattended && this.toolApproval !== "allow")
|
|
43
|
+
throw new Error("Native Copilot cannot confirm unattended tool permissions.");
|
|
44
|
+
await this.refresh();
|
|
45
|
+
}
|
|
46
|
+
async refresh(includeCommands = true) {
|
|
47
|
+
try {
|
|
48
|
+
const [current, listing] = await Promise.all([controlDeadline(this.native.rpc.model.getCurrent(), "Copilot current model"), controlDeadline(this.native.rpc.model.list(), "Copilot models")]);
|
|
49
|
+
if (this.closed)
|
|
50
|
+
return;
|
|
51
|
+
if (!Array.isArray(listing.list) || listing.list.length > 500)
|
|
52
|
+
throw new Error("Invalid Copilot model catalog.");
|
|
53
|
+
const models = listing.list.map(record), metadata = models.find(model => model.id === current.modelId), supports = record(record(metadata?.capabilities).supports);
|
|
54
|
+
const levels = metadata?.supportedReasoningEfforts ?? supports.reasoning_effort;
|
|
55
|
+
const settings = [{ id: "model", category: "model", label: "Model", value: current.modelId ?? null, mutable: models.length > 0, scope: "next_turn", description: "Native model switches can remain queued until the current turn finishes.", options: uniqueOptions(models.map(model => ({ value: string(model.id), label: string(model.name) || string(model.id) }))) }, this.permissions()];
|
|
56
|
+
if (Array.isArray(levels) && levels.length)
|
|
57
|
+
settings.push({ id: "effort", category: "reasoning", label: "Reasoning effort", value: current.reasoningEffort ?? null, mutable: true, scope: "next_turn", description: "Omitted effort follows native defaults. Changes apply to subsequent turns.", options: uniqueOptions(levels.filter(value => typeof value === "string").map(value => ({ value, label: value }))) });
|
|
58
|
+
this.store.update({ settings, settingsError: null });
|
|
59
|
+
for (const [id, pending] of this.pending)
|
|
60
|
+
if (pending.model === current.modelId) {
|
|
61
|
+
this.pending.delete(id);
|
|
62
|
+
pending.resolve();
|
|
63
|
+
this.confirmed?.(id);
|
|
64
|
+
}
|
|
65
|
+
if (!this.pending.size && this.pollTimer) {
|
|
66
|
+
clearInterval(this.pollTimer);
|
|
67
|
+
this.pollTimer = undefined;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
if (!this.closed)
|
|
72
|
+
this.store.update({ settings: [this.permissions()], settingsError: controlError(error) });
|
|
73
|
+
}
|
|
74
|
+
if (!includeCommands)
|
|
75
|
+
return;
|
|
76
|
+
try {
|
|
77
|
+
if (this.skillDiscoveryError)
|
|
78
|
+
throw new Error(this.skillDiscoveryError);
|
|
79
|
+
await controlDeadline(this.native.rpc.skills.ensureLoaded(), "Copilot skill loading");
|
|
80
|
+
const { skills } = await controlDeadline(this.native.rpc.skills.list(), "Copilot skill listing");
|
|
81
|
+
if (this.closed)
|
|
82
|
+
return;
|
|
83
|
+
const commands = skills.filter(skill => skill.enabled && skill.userInvocable).map(skill => ({ id: skill.name, name: skill.commandName ?? skill.name, description: (skill.description || "Copilot skill").slice(0, 1000), argumentHint: skill.argumentHint?.slice(0, 1000) || null, available: true }));
|
|
84
|
+
if (commands.length > 500)
|
|
85
|
+
throw new Error("Copilot command directory exceeded its bound.");
|
|
86
|
+
this.store.update({ commands, commandsError: null });
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
if (!this.closed)
|
|
90
|
+
this.store.update({ commands: [], commandsError: controlError(error) });
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
async set(id, value, operationId, revision) {
|
|
94
|
+
this.store.setting(id, value, revision);
|
|
95
|
+
if (this.closed)
|
|
96
|
+
throw new Error("Native session closed.");
|
|
97
|
+
if (id === "tool_approval") {
|
|
98
|
+
const operation = this.native.rpc.permissions.setApproveAll({ enabled: value === "allow" }).then(result => { if (!result.success)
|
|
99
|
+
throw new Error("Copilot did not confirm tool permission update."); if (this.closed)
|
|
100
|
+
throw new Error("Native session closed."); this.toolApproval = value; this.store.update({ settings: [...this.store.value.settings.filter(item => item.id !== id), this.permissions()] }); this.confirmed?.(operationId); });
|
|
101
|
+
try {
|
|
102
|
+
await controlDeadline(operation, "Copilot permission update");
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
this.toolApproval = null;
|
|
106
|
+
this.store.update({ settings: [...this.store.value.settings.filter(item => item.id !== id), this.permissions()], settingsError: controlError(error) });
|
|
107
|
+
throw error;
|
|
108
|
+
}
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
if (id === "effort") {
|
|
112
|
+
await controlDeadline(this.native.rpc.model.setReasoningEffort({ reasoningEffort: value }), "Copilot effort update");
|
|
113
|
+
await this.refresh();
|
|
114
|
+
if (this.store.value.settings.find(item => item.id === id)?.value !== value)
|
|
115
|
+
throw new Error("Copilot did not confirm applied effort.");
|
|
116
|
+
this.confirmed?.(operationId);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const response = await controlDeadline(this.native.rpc.model.switchTo({ modelId: value, deferIfModelChangeQueued: true }), "Copilot model update");
|
|
120
|
+
let resolve, reject;
|
|
121
|
+
const confirmation = new Promise((ok, fail) => { resolve = ok; reject = fail; });
|
|
122
|
+
void confirmation.catch(() => { });
|
|
123
|
+
this.pending.set(operationId, { model: value, resolve, reject });
|
|
124
|
+
await this.refresh();
|
|
125
|
+
if (this.pending.has(operationId)) {
|
|
126
|
+
if (!response.deferred) {
|
|
127
|
+
this.pending.delete(operationId);
|
|
128
|
+
throw new Error("Copilot model readback did not match the requested model.");
|
|
129
|
+
}
|
|
130
|
+
this.pollTimer ??= setInterval(() => { if (this.polling || this.closed)
|
|
131
|
+
return; this.polling = true; void this.refresh(false).finally(() => { this.polling = false; }); }, 1000);
|
|
132
|
+
this.pollTimer.unref();
|
|
133
|
+
}
|
|
134
|
+
await controlDeadline(confirmation, "Copilot queued model confirmation");
|
|
135
|
+
}
|
|
136
|
+
async invoke(id, args, revision) { const command = this.store.command(id, revision); if (this.closed)
|
|
137
|
+
throw new NativeRpcError(-32602, "Native session closed."); const result = await controlDeadline(this.native.rpc.commands.invoke({ name: command.name, input: args }), "Copilot command"); if (result.runtimeSettingsChanged)
|
|
138
|
+
await this.refresh(); return result; }
|
|
139
|
+
close() { this.closed = true; if (this.pollTimer)
|
|
140
|
+
clearInterval(this.pollTimer); for (const item of this.pending.values())
|
|
141
|
+
item.reject(new Error("Native Copilot closed before model confirmation.")); this.pending.clear(); }
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=controls-copilot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controls-copilot.js","sourceRoot":"","sources":["../../../../src/commands/controller/providers/controls-copilot.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,YAAY,EAAE,aAAa,EAAuB,MAAM,eAAe,CAAC;AACpH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjE,MAAM,OAAO,eAAe;IAKG,MAAM;IAAwD,SAAS;IAAwE,mBAAmB;IAJtL,KAAK,CAAmB;IACzB,YAAY,GAAkB,IAAI,CAAC;IACnC,OAAO,GAAG,IAAI,GAAG,EAA0E,CAAC;IAC5F,SAAS,CAA6C;IAAS,OAAO,GAAG,KAAK,CAAC;IAAS,MAAM,GAAG,KAAK,CAAC;IAC/G,YAA6B,MAAsB,EAAE,OAAmB,EAAmB,SAAyC,EAAE,aAAa,GAAG,GAAG,EAAmB,mBAAmB,GAAkB,IAAI;sBAAxL,MAAM;yBAAwD,SAAS;mCAAwE,mBAAmB;QAA0B,IAAI,CAAC,KAAK,GAAG,IAAI,gBAAgB,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;IAAC,CAAC;IAC7Q,WAAW,KAAqB,OAAO,EAAE,EAAE,EAAE,eAAe,EAAE,QAAQ,EAAE,YAAY,EAAE,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,OAAO,EAAE,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,aAAa,KAAK,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,6FAA6F,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,kBAAkB,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO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I,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;QAAE,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;CAC/N"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type SessionControls, type SessionSetting, type SessionNativeCommand } from "../../../session/controls.js";
|
|
2
|
+
export type { SessionControls, SessionSetting, SessionNativeCommand };
|
|
3
|
+
export declare const controlError: (error: unknown) => string;
|
|
4
|
+
export declare const controlDeadline: <T>(operation: Promise<T>, label: string, ms?: number) => Promise<T>;
|
|
5
|
+
export declare class ProviderControls {
|
|
6
|
+
private readonly changed;
|
|
7
|
+
value: SessionControls;
|
|
8
|
+
constructor(changed: () => void, floor?: string);
|
|
9
|
+
update(patch: Partial<Omit<SessionControls, "revision">>): void;
|
|
10
|
+
requireRevision(revision: string): void;
|
|
11
|
+
setting(id: string, value: string, revision: string): SessionSetting;
|
|
12
|
+
command(id: string, revision: string): SessionNativeCommand;
|
|
13
|
+
}
|
|
14
|
+
export declare const uniqueOptions: (values: readonly {
|
|
15
|
+
value: string;
|
|
16
|
+
label: string;
|
|
17
|
+
}[]) => {
|
|
18
|
+
value: string;
|
|
19
|
+
label: string;
|
|
20
|
+
}[];
|
|
21
|
+
export declare const sameControlValue: (left: unknown, right: unknown) => boolean;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { parseSessionControls } from "../../../session/controls.js";
|
|
2
|
+
import { NativeRpcError } from "./native-rpc.js";
|
|
3
|
+
export const controlError = (error) => (error instanceof Error ? error.message : String(error)).slice(0, 1000) || "Native controls unavailable.";
|
|
4
|
+
export const controlDeadline = (operation, label, ms = 30_000) => new Promise((resolve, reject) => {
|
|
5
|
+
const timer = setTimeout(() => reject(new Error(`${label} was not confirmed. Check native state before retrying.`)), ms);
|
|
6
|
+
operation.then(result => { clearTimeout(timer); resolve(result); }, error => { clearTimeout(timer); reject(error); });
|
|
7
|
+
});
|
|
8
|
+
export class ProviderControls {
|
|
9
|
+
changed;
|
|
10
|
+
value = { revision: "1", settings: [], commands: [], settingsError: null, commandsError: null };
|
|
11
|
+
constructor(changed, floor = "0") {
|
|
12
|
+
this.changed = changed;
|
|
13
|
+
if (!/^(0|[1-9][0-9]{0,18})$/.test(floor))
|
|
14
|
+
throw new Error("Invalid native control revision floor.");
|
|
15
|
+
this.value = parseSessionControls({ ...this.value, revision: String(BigInt(floor) + 1n) });
|
|
16
|
+
}
|
|
17
|
+
update(patch) {
|
|
18
|
+
const next = { ...this.value, ...patch };
|
|
19
|
+
if (sameControlValue(next, this.value))
|
|
20
|
+
return;
|
|
21
|
+
this.value = parseSessionControls({ ...next, revision: String(BigInt(this.value.revision) + 1n) });
|
|
22
|
+
this.changed();
|
|
23
|
+
}
|
|
24
|
+
requireRevision(revision) { if (revision !== this.value.revision)
|
|
25
|
+
throw new NativeRpcError(-32602, "The native control directory changed. Refresh and choose again."); }
|
|
26
|
+
setting(id, value, revision) {
|
|
27
|
+
this.requireRevision(revision);
|
|
28
|
+
const setting = this.value.settings.find(item => item.id === id);
|
|
29
|
+
if (!setting?.mutable || !setting.options.some(option => option.value === value))
|
|
30
|
+
throw new NativeRpcError(-32602, "The requested native setting is unavailable.");
|
|
31
|
+
return setting;
|
|
32
|
+
}
|
|
33
|
+
command(id, revision) {
|
|
34
|
+
this.requireRevision(revision);
|
|
35
|
+
const command = this.value.commands.find(item => item.id === id);
|
|
36
|
+
if (!command?.available)
|
|
37
|
+
throw new NativeRpcError(-32602, "The requested native command is unavailable.");
|
|
38
|
+
return command;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export const uniqueOptions = (values) => [...new Map(values.filter(item => item.value && item.label).map(item => [item.value, item])).values()].slice(0, 500);
|
|
42
|
+
export const sameControlValue = (left, right) => {
|
|
43
|
+
if (left === right)
|
|
44
|
+
return true;
|
|
45
|
+
if (Array.isArray(left) && Array.isArray(right))
|
|
46
|
+
return left.length === right.length && left.every((value, index) => sameControlValue(value, right[index]));
|
|
47
|
+
if (left && right && typeof left === "object" && typeof right === "object" && !Array.isArray(left) && !Array.isArray(right)) {
|
|
48
|
+
const a = left, b = right;
|
|
49
|
+
return Object.keys(a).length === Object.keys(b).length && Object.keys(a).every(key => sameControlValue(a[key], b[key]));
|
|
50
|
+
}
|
|
51
|
+
return false;
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=controls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controls.js","sourceRoot":"","sources":["../../../../src/commands/controller/providers/controls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAwE,MAAM,8BAA8B,CAAC;AAC1I,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAc,EAAU,EAAE,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,8BAA8B,CAAC;AAClK,MAAM,CAAC,MAAM,eAAe,GAAG,CAAI,SAAqB,EAAE,KAAa,EAAE,EAAE,GAAG,MAAM,EAAc,EAAE,CAAC,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;IACnI,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,GAAG,KAAK,yDAAyD,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACzH,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC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C,EAAE,GAAG,CAAC,CAAC;AAE3M,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,IAAa,EAAE,KAAc,EAAW,EAAE;IACzE,IAAI,IAAI,KAAK,KAAK;QAAE,OAAO,IAAI,CAAC;IAChC,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,gBAAgB,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC5J,IAAI,IAAI,IAAI,KAAK,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAAC,MAAM,CAAC,GAAG,IAA+B,EAAE,CAAC,GAAG,KAAgC,CAAC;QAAC,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAAC,CAAC;IAC1U,OAAO,KAAK,CAAC;AACf,CAAC,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { CopilotSession, ElicitationResult, ExitPlanModeResult, SessionConfig, SessionEvent } from "@github/copilot-sdk";
|
|
2
|
+
import { type InteractionResponse } from "../../../session/protocol.js";
|
|
3
|
+
import type { ProviderEntry, ProviderReceipt } from "./types.js";
|
|
4
|
+
type Question = Parameters<NonNullable<SessionConfig["onUserInputRequest"]>>[0];
|
|
5
|
+
type QuestionReply = {
|
|
6
|
+
answer: string;
|
|
7
|
+
wasFreeform: boolean;
|
|
8
|
+
};
|
|
9
|
+
type Elicitation = Parameters<NonNullable<SessionConfig["onElicitationRequest"]>>[0];
|
|
10
|
+
type Plan = Parameters<NonNullable<SessionConfig["onExitPlanModeRequest"]>>[0];
|
|
11
|
+
type Permission = Parameters<CopilotSession["rpc"]["permissions"]["handlePendingPermissionRequest"]>[0];
|
|
12
|
+
export type CopilotInteractionOptions = {
|
|
13
|
+
sessionId: string;
|
|
14
|
+
onTimeline(entry: ProviderEntry): void;
|
|
15
|
+
onChange(): void;
|
|
16
|
+
permissionRpc(input: Permission): Promise<{
|
|
17
|
+
success: boolean;
|
|
18
|
+
}>;
|
|
19
|
+
confirmationTimeoutMs?: number;
|
|
20
|
+
};
|
|
21
|
+
/** SDK callbacks carry no request ID; only an unambiguous full payload can bind them to a native event. */
|
|
22
|
+
export declare class CopilotInteractions {
|
|
23
|
+
private readonly options;
|
|
24
|
+
private readonly pending;
|
|
25
|
+
private readonly history;
|
|
26
|
+
private readonly seen;
|
|
27
|
+
private readonly tools;
|
|
28
|
+
private closed;
|
|
29
|
+
constructor(options: CopilotInteractionOptions);
|
|
30
|
+
get waiting(): boolean;
|
|
31
|
+
get pendingIds(): readonly string[];
|
|
32
|
+
onPermissionRequest(): {
|
|
33
|
+
kind: "no-result";
|
|
34
|
+
};
|
|
35
|
+
private publish;
|
|
36
|
+
private error;
|
|
37
|
+
accept(event: SessionEvent, history?: boolean): void;
|
|
38
|
+
bindQuestion(payload: Question): Promise<QuestionReply>;
|
|
39
|
+
bindElicitation(payload: Elicitation): Promise<ElicitationResult>;
|
|
40
|
+
bindPlan(payload: Plan): Promise<ExitPlanModeResult>;
|
|
41
|
+
private bind;
|
|
42
|
+
private retire;
|
|
43
|
+
cancelOwner(owner?: string | null): void;
|
|
44
|
+
dispose(error?: Error): void;
|
|
45
|
+
respond(id: string, revision: string, input: InteractionResponse): Promise<ProviderReceipt>;
|
|
46
|
+
}
|
|
47
|
+
export {};
|