@skrr-ai/cli 0.1.178 → 0.1.180
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/commands/code/index.js +5 -0
- package/dist/commands/diagnostics/inference-smoke.d.ts +13 -0
- package/dist/commands/diagnostics/inference-smoke.js +50 -0
- package/dist/commands/harnesses/evaluations/evidence.d.ts +22 -0
- package/dist/commands/harnesses/evaluations/evidence.js +92 -0
- package/dist/commands/harnesses/evaluations/fixed-tool.d.ts +10 -0
- package/dist/commands/harnesses/evaluations/fixed-tool.js +189 -0
- package/dist/commands/harnesses/evaluations/grant.d.ts +30 -0
- package/dist/commands/harnesses/evaluations/grant.js +109 -0
- package/dist/commands/harnesses/evaluations/list.d.ts +18 -0
- package/dist/commands/harnesses/evaluations/list.js +73 -0
- package/dist/commands/harnesses/evaluations/platform-h9-turn.d.ts +13 -0
- package/dist/commands/harnesses/evaluations/platform-h9-turn.js +322 -0
- package/dist/commands/harnesses/evaluations/revoke.d.ts +19 -0
- package/dist/commands/harnesses/evaluations/revoke.js +45 -0
- package/dist/commands/harnesses/evaluations/show.d.ts +14 -0
- package/dist/commands/harnesses/evaluations/show.js +46 -0
- package/dist/commands/harnesses/list.d.ts +1 -0
- package/dist/commands/harnesses/list.js +11 -2
- package/dist/commands/harnesses/show.js +5 -0
- package/dist/commands/machines/hosted/identity-evaluations/issue.d.ts +12 -0
- package/dist/commands/machines/hosted/identity-evaluations/issue.js +40 -0
- package/dist/commands/machines/hosted/identity-evaluations/revoke.d.ts +11 -0
- package/dist/commands/machines/hosted/identity-evaluations/revoke.js +21 -0
- package/dist/commands/machines/hosted/identity-evaluations/show.d.ts +8 -0
- package/dist/commands/machines/hosted/identity-evaluations/show.js +20 -0
- package/dist/commands/machines/hosted/start.d.ts +1 -0
- package/dist/commands/machines/hosted/start.js +6 -0
- package/dist/lib/agentic-stream.d.ts +3 -0
- package/dist/lib/agentic-stream.js +63 -1
- package/dist/lib/copilot-fixed-probe-runner.d.ts +72 -0
- package/dist/lib/copilot-fixed-probe-runner.js +213 -0
- package/dist/lib/copilot-fixed-probe.d.ts +61 -0
- package/dist/lib/copilot-fixed-probe.js +223 -0
- package/dist/lib/first-party-harness-broker.d.ts +5 -0
- package/dist/lib/first-party-harness-broker.js +99 -0
- package/dist/lib/h9-platform-stream.d.ts +63 -0
- package/dist/lib/h9-platform-stream.js +317 -0
- package/dist/lib/h9-prior-stream.d.ts +44 -0
- package/dist/lib/h9-prior-stream.js +217 -0
- package/dist/lib/harness-evaluations.d.ts +251 -0
- package/dist/lib/harness-evaluations.js +66 -0
- package/dist/lib/harness-labels.d.ts +10 -0
- package/dist/lib/harness-labels.js +23 -0
- package/dist/lib/hosted-identity-evaluations.d.ts +26 -0
- package/dist/lib/hosted-identity-evaluations.js +18 -0
- package/dist/lib/hosted-machines.d.ts +1 -0
- package/dist/lib/inference-overload-smoke-contract.d.ts +53 -0
- package/dist/lib/inference-overload-smoke-contract.js +192 -0
- package/dist/lib/inference-overload-smoke.d.ts +78 -0
- package/dist/lib/inference-overload-smoke.js +350 -0
- package/dist/lib/operator-probe-files.d.ts +6 -0
- package/dist/lib/operator-probe-files.js +68 -0
- package/dist/lib/platform-h9-plan.d.ts +47 -0
- package/dist/lib/platform-h9-plan.js +78 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/codex-model-catalog.json +150 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/inferenceBrokerHarnesses.d.ts +12 -2
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/inferenceBrokerHarnesses.js +12 -5
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/inferenceBrokerHarnesses.d.ts +12 -2
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/inferenceBrokerHarnesses.js +21 -7
- package/dist/node_modules/@skrr-ai/data-provider/index.js +6 -6
- package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/index.d.ts +3 -1
- package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/index.js +23 -1
- package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/managed-haiku-none.d.ts +8 -0
- package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/managed-haiku-none.js +40 -0
- package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/managed-inference-broker.d.ts +11 -20
- package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/managed-inference-broker.js +88 -9
- package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/overload-smoke.d.ts +56 -0
- package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/overload-smoke.js +277 -0
- package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/index.d.ts +3 -1
- package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/index.js +3 -1
- package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/managed-haiku-none.d.ts +8 -0
- package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/managed-haiku-none.js +20 -0
- package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/managed-inference-broker.d.ts +11 -20
- package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/managed-inference-broker.js +105 -12
- package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/overload-smoke.d.ts +56 -0
- package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/overload-smoke.js +261 -0
- package/oclif.manifest.json +1391 -443
- package/package.json +5 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type PublicProjection, type AssistantTextJoiner } from '@skrr-ai/data-provider';
|
|
2
|
+
import type { FixedCopilotPermission } from './copilot-fixed-probe';
|
|
2
3
|
/**
|
|
3
4
|
* Why a question was dismissed when no terminal exists to ask it on. It is the
|
|
4
5
|
* REASON for a dismissal, never an answer: it travels as the value of the
|
|
@@ -196,6 +197,8 @@ export type AgenticStreamOptions = {
|
|
|
196
197
|
*/
|
|
197
198
|
incrementalText?: boolean;
|
|
198
199
|
approveTools?: boolean;
|
|
200
|
+
/** Internal fixed operator probe; never combined with blanket approval or TTY answers. */
|
|
201
|
+
fixedCopilotProbe?: FixedCopilotPermission;
|
|
199
202
|
input?: NodeJS.ReadableStream;
|
|
200
203
|
output?: NodeJS.WritableStream;
|
|
201
204
|
onEvent?: (event: AgenticStreamEvent) => void;
|
|
@@ -933,6 +933,8 @@ class AgenticStreamClient {
|
|
|
933
933
|
return this.terminalResult;
|
|
934
934
|
}
|
|
935
935
|
constructor(options) {
|
|
936
|
+
if (options.fixedCopilotProbe && (options.approveTools || options.input))
|
|
937
|
+
throw new Error('Fixed Copilot probe cannot use blanket or terminal approval');
|
|
936
938
|
this.options = options;
|
|
937
939
|
}
|
|
938
940
|
async run() {
|
|
@@ -1085,6 +1087,7 @@ class AgenticStreamClient {
|
|
|
1085
1087
|
return true;
|
|
1086
1088
|
}
|
|
1087
1089
|
cancel(reason = 'Interrupted by user') {
|
|
1090
|
+
this.options.fixedCopilotProbe?.stop();
|
|
1088
1091
|
if (this.settled || !this.socket)
|
|
1089
1092
|
return;
|
|
1090
1093
|
// A handed-over turn has no relaying server left to carry an interrupt to
|
|
@@ -1101,6 +1104,7 @@ class AgenticStreamClient {
|
|
|
1101
1104
|
this.emit({ type: 'run.cancel_requested', sessionId: this.options.sessionId, reason });
|
|
1102
1105
|
}
|
|
1103
1106
|
close() {
|
|
1107
|
+
this.options.fixedCopilotProbe?.close();
|
|
1104
1108
|
if (this.closed)
|
|
1105
1109
|
return;
|
|
1106
1110
|
this.closed = true;
|
|
@@ -1861,6 +1865,26 @@ class AgenticStreamClient {
|
|
|
1861
1865
|
if (this.replayPermissionDecision(event))
|
|
1862
1866
|
return;
|
|
1863
1867
|
this.emit({ ...event, type: 'permission.requested' });
|
|
1868
|
+
if (this.options.fixedCopilotProbe) {
|
|
1869
|
+
const approved = this.options.fixedCopilotProbe.decide(event);
|
|
1870
|
+
// No legacy unbound response and no continuing/session grant. The server
|
|
1871
|
+
// validates this public context against its own current lifetime and ask.
|
|
1872
|
+
const ordinaryToolAsk = event.purpose === undefined &&
|
|
1873
|
+
event.runtimeElicitation === undefined &&
|
|
1874
|
+
event.toolName !== 'ComputerUse';
|
|
1875
|
+
if (ordinaryToolAsk && event.permissionBinding)
|
|
1876
|
+
await this.sendBoundPermissionDecision(event, approved, {
|
|
1877
|
+
...(event.interactiveAdmission
|
|
1878
|
+
? { interactiveAdmission: event.interactiveAdmission }
|
|
1879
|
+
: {}),
|
|
1880
|
+
...(approved
|
|
1881
|
+
? { scope: 'once' }
|
|
1882
|
+
: { automatic: true, reason: 'Fixed Copilot probe refused this request' }),
|
|
1883
|
+
});
|
|
1884
|
+
if (!approved || this.options.fixedCopilotProbe.refused)
|
|
1885
|
+
this.cancel('Fixed Copilot probe permission refused or unconfirmed');
|
|
1886
|
+
return;
|
|
1887
|
+
}
|
|
1864
1888
|
// Runtime-authored application consent is exclusively an interactive app
|
|
1865
1889
|
// decision. A TTY or --approve-tools is not that authenticated human lane.
|
|
1866
1890
|
// Recognize malformed runtime asks too, so they never fall into generic grants.
|
|
@@ -2004,6 +2028,11 @@ class AgenticStreamClient {
|
|
|
2004
2028
|
event.runtimeElicitation !== undefined ||
|
|
2005
2029
|
event.toolName === 'ComputerUse')
|
|
2006
2030
|
return false;
|
|
2031
|
+
if (this.options.fixedCopilotProbe) {
|
|
2032
|
+
this.options.fixedCopilotProbe.stop('PROBE_REPLAYED_DECISION');
|
|
2033
|
+
this.cancel('Fixed Copilot probe cannot adopt a replayed permission decision');
|
|
2034
|
+
return true;
|
|
2035
|
+
}
|
|
2007
2036
|
const generation = permissionGeneration(event);
|
|
2008
2037
|
if (event.toolUseId) {
|
|
2009
2038
|
this.openPermissionPrompts.get(event.toolUseId)?.abort();
|
|
@@ -2106,6 +2135,9 @@ class AgenticStreamClient {
|
|
|
2106
2135
|
finish({
|
|
2107
2136
|
type: 'permission.response_recorded',
|
|
2108
2137
|
status: result.status,
|
|
2138
|
+
...(this.options.fixedCopilotProbe && result.duplicate === true
|
|
2139
|
+
? { duplicate: true }
|
|
2140
|
+
: {}),
|
|
2109
2141
|
message: 'Response recorded. This does not confirm tool execution or a continuing permission grant.',
|
|
2110
2142
|
});
|
|
2111
2143
|
else
|
|
@@ -2123,11 +2155,21 @@ class AgenticStreamClient {
|
|
|
2123
2155
|
decision: approved ? 'allow' : 'deny',
|
|
2124
2156
|
executionConfirmed: false,
|
|
2125
2157
|
});
|
|
2158
|
+
if (this.options.fixedCopilotProbe) {
|
|
2159
|
+
this.options.fixedCopilotProbe.decisionReceipt(event, approved, result);
|
|
2160
|
+
if (this.options.fixedCopilotProbe.refused)
|
|
2161
|
+
this.cancel('Fixed Copilot probe decision unconfirmed');
|
|
2162
|
+
}
|
|
2126
2163
|
return true;
|
|
2127
2164
|
}
|
|
2128
2165
|
async handleQuestion(event) {
|
|
2129
2166
|
if (this.closed)
|
|
2130
2167
|
return;
|
|
2168
|
+
if (this.options.fixedCopilotProbe) {
|
|
2169
|
+
this.options.fixedCopilotProbe.stop('PROBE_UNEXPECTED_QUESTION');
|
|
2170
|
+
this.cancel('Fixed Copilot probe cannot answer questions');
|
|
2171
|
+
return;
|
|
2172
|
+
}
|
|
2131
2173
|
// The same question can arrive twice (both delivery paths carry it — a
|
|
2132
2174
|
// non-interactive run showed two `question.requested` for one questionId,
|
|
2133
2175
|
// each answered). Answer it once, as tool events are emitted once.
|
|
@@ -2188,6 +2230,13 @@ class AgenticStreamClient {
|
|
|
2188
2230
|
* and close the terminal prompt if this client is still showing it.
|
|
2189
2231
|
*/
|
|
2190
2232
|
handlePermissionCancel(event) {
|
|
2233
|
+
if (this.options.fixedCopilotProbe) {
|
|
2234
|
+
if (this.options.fixedCopilotProbe.answerNotice(event))
|
|
2235
|
+
return;
|
|
2236
|
+
this.options.fixedCopilotProbe.stop('PROBE_PERMISSION_CANCELLED');
|
|
2237
|
+
this.cancel('Fixed Copilot probe permission closed');
|
|
2238
|
+
return;
|
|
2239
|
+
}
|
|
2191
2240
|
const toolUseId = typeof event.toolUseId === 'string' ? event.toolUseId : undefined;
|
|
2192
2241
|
// An unbound ask still being held for its bound twin was cancelled before it was ever shown.
|
|
2193
2242
|
const heldAsk = toolUseId ? this.heldUnboundAsks.get(toolUseId) : undefined;
|
|
@@ -2399,6 +2448,18 @@ class AgenticStreamClient {
|
|
|
2399
2448
|
return appended === undefined ? { ...rest, replace: text } : { ...rest, delta: appended };
|
|
2400
2449
|
}
|
|
2401
2450
|
emit(event) {
|
|
2451
|
+
this.options.fixedCopilotProbe?.observe(event);
|
|
2452
|
+
if (this.options.fixedCopilotProbe?.refused &&
|
|
2453
|
+
[
|
|
2454
|
+
'tool.started',
|
|
2455
|
+
'tool.completed',
|
|
2456
|
+
'permission.cancelled',
|
|
2457
|
+
'stream.gap',
|
|
2458
|
+
'transport.error',
|
|
2459
|
+
'run.handed_over',
|
|
2460
|
+
'text.reset',
|
|
2461
|
+
].includes(event.type))
|
|
2462
|
+
this.cancel('Fixed Copilot probe observed an unexpected or cancelled tool');
|
|
2402
2463
|
this.lastEvent = event;
|
|
2403
2464
|
this.options.onEvent?.(event);
|
|
2404
2465
|
// Any event is proof the stream is alive; the watchdog only fires on real
|
|
@@ -2904,7 +2965,8 @@ exports.AgenticStreamClient = AgenticStreamClient;
|
|
|
2904
2965
|
*/
|
|
2905
2966
|
const REALTIME_HOSTS = new Map([
|
|
2906
2967
|
...Object.values(publicEndpoints_generated_1.OVERSKY_ENVIRONMENT_ENDPOINTS).map((endpoint) => [
|
|
2907
|
-
new URL(endpoint.appUrl).hostname,
|
|
2968
|
+
new URL(endpoint.appUrl).hostname,
|
|
2969
|
+
new URL(endpoint.realtimeUrl).hostname,
|
|
2908
2970
|
]),
|
|
2909
2971
|
[new URL(config_1.LEGACY_PROD_BASE_URL).hostname, `api.${new URL(config_1.LEGACY_PROD_BASE_URL).hostname}`],
|
|
2910
2972
|
]);
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { FixedCopilotPermission } from './copilot-fixed-probe';
|
|
2
|
+
type Row = Record<string, any>;
|
|
3
|
+
export interface CopilotProbePlan {
|
|
4
|
+
schema: 'copilot-fixed-tool-plan.v1';
|
|
5
|
+
operationId: string;
|
|
6
|
+
ownerUserId: string;
|
|
7
|
+
workspaceId: string;
|
|
8
|
+
grantId: string;
|
|
9
|
+
agentId: string;
|
|
10
|
+
harnessId: string;
|
|
11
|
+
daemonId: string;
|
|
12
|
+
version: '1.0.112';
|
|
13
|
+
model: string;
|
|
14
|
+
image: string;
|
|
15
|
+
nonce: string;
|
|
16
|
+
expiresAt: string;
|
|
17
|
+
maxDurationMs: 90000;
|
|
18
|
+
maxSpendUsd: number;
|
|
19
|
+
paidOperationApproved: boolean;
|
|
20
|
+
}
|
|
21
|
+
export declare function validateCopilotProbePlan(value: unknown): CopilotProbePlan;
|
|
22
|
+
/** Ordinary authenticated GET results. A caller's plan/image labels are never attestation. */
|
|
23
|
+
export declare function validateCopilotProbePreflight(p: CopilotProbePlan, principal: string, records: {
|
|
24
|
+
grant: Row;
|
|
25
|
+
agent: Row;
|
|
26
|
+
harness: Row;
|
|
27
|
+
machine: Row;
|
|
28
|
+
}, now?: number): void;
|
|
29
|
+
export interface CopilotProbeTransport {
|
|
30
|
+
principal(): Promise<string>;
|
|
31
|
+
inspect(plan: CopilotProbePlan): Promise<{
|
|
32
|
+
grant: Row;
|
|
33
|
+
agent: Row;
|
|
34
|
+
harness: Row;
|
|
35
|
+
machine: Row;
|
|
36
|
+
}>;
|
|
37
|
+
/** Exactly one normal start call. A lost response is UNKNOWN, never a new request. */
|
|
38
|
+
start(body: Row, deadline: number): Promise<Row>;
|
|
39
|
+
stream(accepted: Row, permission: FixedCopilotPermission, deadline: number): Promise<Row>;
|
|
40
|
+
cancel(accepted: Row): Promise<void>;
|
|
41
|
+
persist(value: Row): void;
|
|
42
|
+
now?: () => number;
|
|
43
|
+
}
|
|
44
|
+
/** No grant, Agent, machine, policy, credential or permission-mode mutation is performed here. */
|
|
45
|
+
export declare function runCopilotFixedProbe(p: CopilotProbePlan, transport: CopilotProbeTransport): Promise<{
|
|
46
|
+
billingClosureClaimed: boolean;
|
|
47
|
+
h9AdmissionClaimed: boolean;
|
|
48
|
+
cloudH1Claimed: boolean;
|
|
49
|
+
ownedResourcesDeleted: boolean;
|
|
50
|
+
permissionRecorded: boolean;
|
|
51
|
+
toolVerified: boolean;
|
|
52
|
+
failure: string | null;
|
|
53
|
+
toolUseId: string | null;
|
|
54
|
+
requestId: string | null;
|
|
55
|
+
interactiveAdmission: import("./copilot-fixed-probe").InteractiveAdmission;
|
|
56
|
+
autonomousRunClaimed: boolean;
|
|
57
|
+
autonomousAttemptClaimed: boolean;
|
|
58
|
+
approvalSource: string;
|
|
59
|
+
schema: string;
|
|
60
|
+
clientRequestId: string;
|
|
61
|
+
grantId: string;
|
|
62
|
+
agentId: string;
|
|
63
|
+
daemonId: string;
|
|
64
|
+
image: string;
|
|
65
|
+
model: string;
|
|
66
|
+
sessionId: any;
|
|
67
|
+
conversationId: any;
|
|
68
|
+
responseMessageId: any;
|
|
69
|
+
outcome: string;
|
|
70
|
+
runtimeStartObserved: boolean;
|
|
71
|
+
}>;
|
|
72
|
+
export {};
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateCopilotProbePlan = validateCopilotProbePlan;
|
|
4
|
+
exports.validateCopilotProbePreflight = validateCopilotProbePreflight;
|
|
5
|
+
exports.runCopilotFixedProbe = runCopilotFixedProbe;
|
|
6
|
+
const copilot_fixed_probe_1 = require("./copilot-fixed-probe");
|
|
7
|
+
const agent_chat_start_1 = require("./agent-chat-start");
|
|
8
|
+
const need = (ok, code) => {
|
|
9
|
+
if (!ok)
|
|
10
|
+
throw new Error(code);
|
|
11
|
+
};
|
|
12
|
+
const id = (value) => typeof value === 'string' && /^[A-Za-z0-9][A-Za-z0-9_.:@-]{0,239}$/.test(value);
|
|
13
|
+
function validateCopilotProbePlan(value) {
|
|
14
|
+
const p = value;
|
|
15
|
+
const keys = [
|
|
16
|
+
'schema',
|
|
17
|
+
'operationId',
|
|
18
|
+
'ownerUserId',
|
|
19
|
+
'workspaceId',
|
|
20
|
+
'grantId',
|
|
21
|
+
'agentId',
|
|
22
|
+
'harnessId',
|
|
23
|
+
'daemonId',
|
|
24
|
+
'version',
|
|
25
|
+
'model',
|
|
26
|
+
'image',
|
|
27
|
+
'nonce',
|
|
28
|
+
'expiresAt',
|
|
29
|
+
'maxDurationMs',
|
|
30
|
+
'maxSpendUsd',
|
|
31
|
+
'paidOperationApproved',
|
|
32
|
+
];
|
|
33
|
+
need(p &&
|
|
34
|
+
typeof p === 'object' &&
|
|
35
|
+
!Array.isArray(p) &&
|
|
36
|
+
JSON.stringify(Object.keys(p).sort()) === JSON.stringify(keys.sort()), 'PROBE_PLAN_SHAPE');
|
|
37
|
+
need(p.schema === 'copilot-fixed-tool-plan.v1' &&
|
|
38
|
+
p.version === '1.0.112' &&
|
|
39
|
+
[
|
|
40
|
+
'operationId',
|
|
41
|
+
'ownerUserId',
|
|
42
|
+
'workspaceId',
|
|
43
|
+
'grantId',
|
|
44
|
+
'agentId',
|
|
45
|
+
'harnessId',
|
|
46
|
+
'daemonId',
|
|
47
|
+
'model',
|
|
48
|
+
'image',
|
|
49
|
+
].every((k) => id(p[k])) &&
|
|
50
|
+
p.maxDurationMs === 90000 &&
|
|
51
|
+
Number.isFinite(p.maxSpendUsd) &&
|
|
52
|
+
p.maxSpendUsd >= 0 &&
|
|
53
|
+
typeof p.paidOperationApproved === 'boolean' &&
|
|
54
|
+
typeof p.expiresAt === 'string' &&
|
|
55
|
+
p.expiresAt.endsWith('Z') &&
|
|
56
|
+
Number.isFinite(Date.parse(p.expiresAt)), 'PROBE_PLAN_VALUES');
|
|
57
|
+
(0, copilot_fixed_probe_1.fixedCopilotCommand)(p.nonce);
|
|
58
|
+
need((0, agent_chat_start_1.isValidStartKey)(`copilot-fixed:${p.operationId}`), 'PROBE_START_IDENTITY_INVALID');
|
|
59
|
+
return Object.freeze({ ...p });
|
|
60
|
+
}
|
|
61
|
+
/** Ordinary authenticated GET results. A caller's plan/image labels are never attestation. */
|
|
62
|
+
function validateCopilotProbePreflight(p, principal, records, now = Date.now()) {
|
|
63
|
+
const { grant: g, agent: a, harness: h, machine: m } = records;
|
|
64
|
+
need(principal === p.ownerUserId && g.ownerUserId === principal, 'PROBE_OWNER_MISMATCH');
|
|
65
|
+
need(p.paidOperationApproved &&
|
|
66
|
+
p.maxSpendUsd > 0 &&
|
|
67
|
+
Date.parse(p.expiresAt) > now &&
|
|
68
|
+
Date.parse(p.expiresAt) <= now + 600000, 'PROBE_OPERATIONAL_GO_REQUIRED');
|
|
69
|
+
need(g.grantId === p.grantId &&
|
|
70
|
+
g.harness === 'copilot-sdk' &&
|
|
71
|
+
g.version === p.version &&
|
|
72
|
+
g.daemonId === p.daemonId &&
|
|
73
|
+
g.state === 'active' &&
|
|
74
|
+
g.active === true &&
|
|
75
|
+
typeof g.expiresAt === 'string' &&
|
|
76
|
+
Date.parse(g.expiresAt) >= now + p.maxDurationMs &&
|
|
77
|
+
Array.isArray(g.models) &&
|
|
78
|
+
g.models.length === 1 &&
|
|
79
|
+
g.models[0] === p.model &&
|
|
80
|
+
Array.isArray(g.admissions) &&
|
|
81
|
+
g.admissions.length === 0 &&
|
|
82
|
+
Number.isFinite(g.maxSpendUsd) &&
|
|
83
|
+
g.maxSpendUsd > 0 &&
|
|
84
|
+
g.maxSpendUsd <= p.maxSpendUsd, 'PROBE_DEDICATED_EVALUATION_GRANT_REQUIRED');
|
|
85
|
+
const targets = a.executionPolicy?.targets?.filter((x) => x.enabled !== false);
|
|
86
|
+
need((a.id ?? a.agent_id) === p.agentId &&
|
|
87
|
+
a.model === p.model &&
|
|
88
|
+
a.author === principal &&
|
|
89
|
+
a.executionPolicy?.mode === 'ordered' &&
|
|
90
|
+
targets?.length === 1 &&
|
|
91
|
+
targets[0].kind === 'harness' &&
|
|
92
|
+
targets[0].harnessId === p.harnessId &&
|
|
93
|
+
(targets[0].advanceOn?.length ?? 0) === 0, 'PROBE_SOLE_HARNESS_REQUIRED');
|
|
94
|
+
need((h.id ?? h._id) === p.harnessId &&
|
|
95
|
+
h.provider === 'copilot-sdk' &&
|
|
96
|
+
h.daemonId === p.daemonId &&
|
|
97
|
+
h.metadata?.cliVersion === p.version &&
|
|
98
|
+
h.metadata?.evaluation?.grantId === p.grantId &&
|
|
99
|
+
h.metadata?.evaluation?.version === p.version, 'PROBE_HARNESS_BINDING');
|
|
100
|
+
need(m.daemonId === p.daemonId &&
|
|
101
|
+
m.image === p.image &&
|
|
102
|
+
!m.unavailable &&
|
|
103
|
+
['hosted-machine', 'dedicated-machine'].includes(m.machineProduct), 'PROBE_ATTESTED_IMAGE_REQUIRED');
|
|
104
|
+
}
|
|
105
|
+
/** No grant, Agent, machine, policy, credential or permission-mode mutation is performed here. */
|
|
106
|
+
async function runCopilotFixedProbe(p, transport) {
|
|
107
|
+
const now = transport.now ?? Date.now;
|
|
108
|
+
validateCopilotProbePreflight(p, await transport.principal(), await transport.inspect(p), now());
|
|
109
|
+
const clientRequestId = `copilot-fixed:${p.operationId}`;
|
|
110
|
+
// Persist the only request identity before dispatch. No model retry/recovery under a new key.
|
|
111
|
+
transport.persist({
|
|
112
|
+
state: 'start-may-be-unacknowledged',
|
|
113
|
+
clientRequestId,
|
|
114
|
+
agentId: p.agentId,
|
|
115
|
+
grantId: p.grantId,
|
|
116
|
+
daemonId: p.daemonId,
|
|
117
|
+
image: p.image,
|
|
118
|
+
});
|
|
119
|
+
const deadline = Math.min(now() + p.maxDurationMs, Date.parse(p.expiresAt));
|
|
120
|
+
const accepted = await transport.start({
|
|
121
|
+
agentId: p.agentId,
|
|
122
|
+
workspaceId: p.workspaceId,
|
|
123
|
+
conversationId: 'new',
|
|
124
|
+
clientRequestId,
|
|
125
|
+
executionEnvironment: 'local',
|
|
126
|
+
preferredDaemonId: p.daemonId,
|
|
127
|
+
permissionMode: 'default',
|
|
128
|
+
text: `Use Bash exactly once to run exactly: ${(0, copilot_fixed_probe_1.fixedCopilotCommand)(p.nonce)}. ` +
|
|
129
|
+
'Use no other tools. Then reply with the printed value.',
|
|
130
|
+
}, deadline);
|
|
131
|
+
let cancellationAttempted = false;
|
|
132
|
+
const cancelOnce = async () => {
|
|
133
|
+
if (cancellationAttempted || !id(accepted.sessionId))
|
|
134
|
+
return;
|
|
135
|
+
cancellationAttempted = true;
|
|
136
|
+
try {
|
|
137
|
+
await transport.cancel(accepted);
|
|
138
|
+
}
|
|
139
|
+
catch {
|
|
140
|
+
transport.persist({
|
|
141
|
+
state: 'cancellation-unconfirmed',
|
|
142
|
+
clientRequestId,
|
|
143
|
+
sessionId: accepted.sessionId,
|
|
144
|
+
physicalStopConfirmed: false,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
try {
|
|
149
|
+
need(accepted.success === true &&
|
|
150
|
+
id(accepted.sessionId) &&
|
|
151
|
+
id(accepted.conversationId) &&
|
|
152
|
+
id(accepted.responseMessageId) &&
|
|
153
|
+
accepted.workspaceId === p.workspaceId, 'PROBE_ACCEPTANCE_MISMATCH');
|
|
154
|
+
need(accepted.runtime?.mode === 'local' &&
|
|
155
|
+
accepted.runtime?.provider === 'copilot-sdk' &&
|
|
156
|
+
accepted.runtime?.daemonId === p.daemonId &&
|
|
157
|
+
accepted.runtime?.agentRuntime === p.harnessId &&
|
|
158
|
+
accepted.runtime?.executionPlan?.selectedExecutionSelector === p.harnessId &&
|
|
159
|
+
accepted.runtime?.executionPlan?.fallbackUsed === false, 'PROBE_ACCEPTED_RUNTIME_MISMATCH');
|
|
160
|
+
const context = (0, copilot_fixed_probe_1.interactiveAdmission)(accepted.interactiveAdmission);
|
|
161
|
+
need(context.sessionId === accepted.sessionId &&
|
|
162
|
+
context.responseMessageId === accepted.responseMessageId, 'PROBE_ACCEPTANCE_CONTEXT_MISMATCH');
|
|
163
|
+
const permission = new copilot_fixed_probe_1.FixedCopilotPermission(context, p.nonce, deadline, now);
|
|
164
|
+
transport.persist({
|
|
165
|
+
state: 'accepted',
|
|
166
|
+
clientRequestId,
|
|
167
|
+
sessionId: accepted.sessionId,
|
|
168
|
+
conversationId: accepted.conversationId,
|
|
169
|
+
responseMessageId: accepted.responseMessageId,
|
|
170
|
+
interactiveAdmission: context,
|
|
171
|
+
});
|
|
172
|
+
const result = await transport.stream(accepted, permission, deadline);
|
|
173
|
+
const facts = permission.result();
|
|
174
|
+
const receipt = {
|
|
175
|
+
schema: 'copilot-fixed-tool-result.v1',
|
|
176
|
+
clientRequestId,
|
|
177
|
+
grantId: p.grantId,
|
|
178
|
+
agentId: p.agentId,
|
|
179
|
+
daemonId: p.daemonId,
|
|
180
|
+
image: p.image,
|
|
181
|
+
model: p.model,
|
|
182
|
+
sessionId: accepted.sessionId,
|
|
183
|
+
conversationId: accepted.conversationId,
|
|
184
|
+
responseMessageId: accepted.responseMessageId,
|
|
185
|
+
outcome: result.status === 'completed' && result.runtimeStartObserved === true && facts.toolVerified
|
|
186
|
+
? 'fixed-tool-observed'
|
|
187
|
+
: 'inconclusive',
|
|
188
|
+
runtimeStartObserved: result.runtimeStartObserved === true,
|
|
189
|
+
...facts,
|
|
190
|
+
billingClosureClaimed: false,
|
|
191
|
+
h9AdmissionClaimed: false,
|
|
192
|
+
cloudH1Claimed: false,
|
|
193
|
+
ownedResourcesDeleted: false,
|
|
194
|
+
};
|
|
195
|
+
transport.persist(receipt);
|
|
196
|
+
if (receipt.outcome !== 'fixed-tool-observed')
|
|
197
|
+
await cancelOnce();
|
|
198
|
+
return receipt;
|
|
199
|
+
}
|
|
200
|
+
catch (error) {
|
|
201
|
+
// A response from an older server may name a live turn but no new context.
|
|
202
|
+
// Never leave that turn running merely because this client refuses approval.
|
|
203
|
+
transport.persist({
|
|
204
|
+
state: 'inconclusive-cleanup-required',
|
|
205
|
+
clientRequestId,
|
|
206
|
+
...(id(accepted.sessionId) ? { sessionId: accepted.sessionId } : {}),
|
|
207
|
+
...(id(accepted.responseMessageId) ? { responseMessageId: accepted.responseMessageId } : {}),
|
|
208
|
+
physicalStopConfirmed: false,
|
|
209
|
+
});
|
|
210
|
+
await cancelOnce();
|
|
211
|
+
throw error;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/** OSK-24469: one fixed permission response, never a session/tool-policy grant.
|
|
2
|
+
* All identities come from the authenticated normal admission and its server ask.
|
|
3
|
+
* An interactive generation is NOT an autonomous run or attempt identifier.
|
|
4
|
+
*/
|
|
5
|
+
export type InteractiveAdmission = {
|
|
6
|
+
version: 1;
|
|
7
|
+
kind: 'interactive';
|
|
8
|
+
sessionId: string;
|
|
9
|
+
responseMessageId: string;
|
|
10
|
+
generation: string;
|
|
11
|
+
};
|
|
12
|
+
export type InteractivePermissionAdmission = InteractiveAdmission & {
|
|
13
|
+
requestId: string;
|
|
14
|
+
};
|
|
15
|
+
type Frame = Record<string, unknown>;
|
|
16
|
+
export declare function interactiveAdmission(value: unknown): InteractiveAdmission;
|
|
17
|
+
export declare function fixedCopilotCommand(nonce: string): string;
|
|
18
|
+
export declare function copilotPlatformScratchDirectory(nonce: string): string;
|
|
19
|
+
/** Create a private, non-existing directory and remove it before reporting successful exit. */
|
|
20
|
+
export declare function copilotPlatformScratchCommand(nonce: string): string;
|
|
21
|
+
/** Constructed only after normal authenticated owner/grant/image/sole-Harness checks. */
|
|
22
|
+
export declare class FixedCopilotPermission {
|
|
23
|
+
private readonly deadline;
|
|
24
|
+
private readonly now;
|
|
25
|
+
private readonly matchesOutput;
|
|
26
|
+
private readonly platformCopilotScratch;
|
|
27
|
+
private readonly admission;
|
|
28
|
+
private readonly command;
|
|
29
|
+
private readonly output;
|
|
30
|
+
private claimed;
|
|
31
|
+
private announced;
|
|
32
|
+
private recorded;
|
|
33
|
+
private completed;
|
|
34
|
+
private failure;
|
|
35
|
+
private stopped;
|
|
36
|
+
constructor(admission: unknown, nonce: string, deadline: number, now?: () => number, matchesOutput?: (actual: unknown, expected: string) => boolean, platformCopilotScratch?: boolean);
|
|
37
|
+
stop(reason?: string): void;
|
|
38
|
+
close(): void;
|
|
39
|
+
get refused(): boolean;
|
|
40
|
+
/** The exact answered/admitted notice dismisses the prompt without proving execution. */
|
|
41
|
+
answerNotice(frame: Frame): boolean;
|
|
42
|
+
private refuse;
|
|
43
|
+
private active;
|
|
44
|
+
private tool;
|
|
45
|
+
/** Synchronous consumption happens BEFORE any asynchronous decision transport. */
|
|
46
|
+
decide(frame: Frame): boolean;
|
|
47
|
+
decisionReceipt(frame: Frame, approved: boolean, receipt: Frame): void;
|
|
48
|
+
observe(frame: Frame): void;
|
|
49
|
+
result(): {
|
|
50
|
+
permissionRecorded: boolean;
|
|
51
|
+
toolVerified: boolean;
|
|
52
|
+
failure: string | null;
|
|
53
|
+
toolUseId: string | null;
|
|
54
|
+
requestId: string | null;
|
|
55
|
+
interactiveAdmission: InteractiveAdmission;
|
|
56
|
+
autonomousRunClaimed: boolean;
|
|
57
|
+
autonomousAttemptClaimed: boolean;
|
|
58
|
+
approvalSource: string;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
export {};
|