@paperclipai/server 2026.830.0-canary.0 → 2026.830.0-canary.2
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/build-info.json +1 -1
- package/dist/services/productivity-review.d.ts +1 -1
- package/dist/vendor/paperclip-runner/backends/harness-driver-backend.d.ts +164 -0
- package/dist/vendor/paperclip-runner/backends/harness-driver-backend.d.ts.map +1 -0
- package/dist/vendor/paperclip-runner/backends/harness-driver-backend.js +395 -0
- package/dist/vendor/paperclip-runner/backends/harness-driver-backend.js.map +1 -0
- package/dist/vendor/paperclip-runner/backends/runtime-context.d.ts +4 -0
- package/dist/vendor/paperclip-runner/backends/runtime-context.d.ts.map +1 -0
- package/dist/vendor/paperclip-runner/backends/runtime-context.js +35 -0
- package/dist/vendor/paperclip-runner/backends/runtime-context.js.map +1 -0
- package/dist/vendor/paperclip-runner/conformance/control-plane-port.d.ts +99 -0
- package/dist/vendor/paperclip-runner/conformance/control-plane-port.d.ts.map +1 -0
- package/dist/vendor/paperclip-runner/conformance/control-plane-port.js +169 -0
- package/dist/vendor/paperclip-runner/conformance/control-plane-port.js.map +1 -0
- package/dist/vendor/paperclip-runner/conformance/harness-driver.d.ts +41 -0
- package/dist/vendor/paperclip-runner/conformance/harness-driver.d.ts.map +1 -0
- package/dist/vendor/paperclip-runner/conformance/harness-driver.js +166 -0
- package/dist/vendor/paperclip-runner/conformance/harness-driver.js.map +1 -0
- package/dist/vendor/paperclip-runner/contracts/control-plane-port.d.ts +66 -0
- package/dist/vendor/paperclip-runner/contracts/control-plane-port.d.ts.map +1 -0
- package/dist/vendor/paperclip-runner/contracts/control-plane-port.js +2 -0
- package/dist/vendor/paperclip-runner/contracts/control-plane-port.js.map +1 -0
- package/dist/vendor/paperclip-runner/contracts/harness-driver.d.ts +283 -0
- package/dist/vendor/paperclip-runner/contracts/harness-driver.d.ts.map +1 -0
- package/dist/vendor/paperclip-runner/contracts/harness-driver.js +178 -0
- package/dist/vendor/paperclip-runner/contracts/harness-driver.js.map +1 -0
- package/dist/vendor/paperclip-runner/contracts/native-session-backend.d.ts +134 -0
- package/dist/vendor/paperclip-runner/contracts/native-session-backend.d.ts.map +1 -0
- package/dist/vendor/paperclip-runner/contracts/native-session-backend.js +2 -0
- package/dist/vendor/paperclip-runner/contracts/native-session-backend.js.map +1 -0
- package/dist/vendor/paperclip-runner/index.d.ts +6 -0
- package/dist/vendor/paperclip-runner/index.d.ts.map +1 -1
- package/dist/vendor/paperclip-runner/index.js +6 -0
- package/dist/vendor/paperclip-runner/index.js.map +1 -1
- package/dist/vendor/paperclip-runner/mock-core/capability-control-plane-types.d.ts +425 -0
- package/dist/vendor/paperclip-runner/mock-core/capability-control-plane-types.d.ts.map +1 -0
- package/dist/vendor/paperclip-runner/mock-core/capability-control-plane-types.js +109 -0
- package/dist/vendor/paperclip-runner/mock-core/capability-control-plane-types.js.map +1 -0
- package/dist/vendor/paperclip-runner/mock-core/capability-mock-control-plane-adapter.d.ts +37 -0
- package/dist/vendor/paperclip-runner/mock-core/capability-mock-control-plane-adapter.d.ts.map +1 -0
- package/dist/vendor/paperclip-runner/mock-core/capability-mock-control-plane-adapter.js +1336 -0
- package/dist/vendor/paperclip-runner/mock-core/capability-mock-control-plane-adapter.js.map +1 -0
- package/dist/vendor/paperclip-runner/mock-core/deterministic-harness-driver.d.ts +16 -0
- package/dist/vendor/paperclip-runner/mock-core/deterministic-harness-driver.d.ts.map +1 -0
- package/dist/vendor/paperclip-runner/mock-core/deterministic-harness-driver.js +389 -0
- package/dist/vendor/paperclip-runner/mock-core/deterministic-harness-driver.js.map +1 -0
- package/dist/vendor/paperclip-runner/mock-core/mock-control-plane-adapter.d.ts +21 -0
- package/dist/vendor/paperclip-runner/mock-core/mock-control-plane-adapter.d.ts.map +1 -0
- package/dist/vendor/paperclip-runner/mock-core/mock-control-plane-adapter.js +153 -0
- package/dist/vendor/paperclip-runner/mock-core/mock-control-plane-adapter.js.map +1 -0
- package/dist/vendor/paperclip-runner/native-session-runtime.d.ts +59 -0
- package/dist/vendor/paperclip-runner/native-session-runtime.d.ts.map +1 -0
- package/dist/vendor/paperclip-runner/native-session-runtime.js +1020 -0
- package/dist/vendor/paperclip-runner/native-session-runtime.js.map +1 -0
- package/dist/vendor/paperclip-runner/protocol/conformance-fixture.d.ts +12 -0
- package/dist/vendor/paperclip-runner/protocol/conformance-fixture.d.ts.map +1 -0
- package/dist/vendor/paperclip-runner/protocol/conformance-fixture.js +96 -0
- package/dist/vendor/paperclip-runner/protocol/conformance-fixture.js.map +1 -0
- package/dist/vendor/paperclip-runner/protocol/generated/schema-bundle.d.ts +6 -4
- package/dist/vendor/paperclip-runner/protocol/generated/schema-bundle.d.ts.map +1 -1
- package/dist/vendor/paperclip-runner/protocol/generated/schema-bundle.js +10 -3
- package/dist/vendor/paperclip-runner/protocol/generated/schema-bundle.js.map +1 -1
- package/dist/vendor/paperclip-runner/protocol/replay-contract.d.ts.map +1 -1
- package/dist/vendor/paperclip-runner/protocol/replay-contract.js +52 -12
- package/dist/vendor/paperclip-runner/protocol/replay-contract.js.map +1 -1
- package/dist/vendor/paperclip-runner/protocol/semantic-tool-receipts.d.ts +78 -0
- package/dist/vendor/paperclip-runner/protocol/semantic-tool-receipts.d.ts.map +1 -0
- package/dist/vendor/paperclip-runner/protocol/semantic-tool-receipts.js +140 -0
- package/dist/vendor/paperclip-runner/protocol/semantic-tool-receipts.js.map +1 -0
- package/dist/vendor/paperclip-runner/testing.d.ts +8 -0
- package/dist/vendor/paperclip-runner/testing.d.ts.map +1 -1
- package/dist/vendor/paperclip-runner/testing.js +8 -0
- package/dist/vendor/paperclip-runner/testing.js.map +1 -1
- package/dist/vendor/paperclip-runner/tools/capability-semantic-tool-types.d.ts +167 -0
- package/dist/vendor/paperclip-runner/tools/capability-semantic-tool-types.d.ts.map +1 -0
- package/dist/vendor/paperclip-runner/tools/capability-semantic-tool-types.js +13 -0
- package/dist/vendor/paperclip-runner/tools/capability-semantic-tool-types.js.map +1 -0
- package/dist/vendor/paperclip-runner/tracer/conformance-runner.d.ts +19 -0
- package/dist/vendor/paperclip-runner/tracer/conformance-runner.d.ts.map +1 -0
- package/dist/vendor/paperclip-runner/tracer/conformance-runner.js +36 -0
- package/dist/vendor/paperclip-runner/tracer/conformance-runner.js.map +1 -0
- package/package.json +18 -18
package/dist/build-info.json
CHANGED
|
@@ -61,11 +61,11 @@ export declare function productivityReviewService(db: Db, deps?: {
|
|
|
61
61
|
now?: Date;
|
|
62
62
|
thresholds?: Partial<ProductivityReviewThresholds>;
|
|
63
63
|
}) => Promise<{
|
|
64
|
+
reason?: undefined;
|
|
64
65
|
held: false;
|
|
65
66
|
reviewIssueId?: undefined;
|
|
66
67
|
reviewIdentifier?: undefined;
|
|
67
68
|
trigger?: undefined;
|
|
68
|
-
reason?: undefined;
|
|
69
69
|
} | {
|
|
70
70
|
held: true;
|
|
71
71
|
reviewIssueId: string;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import type { HarnessDriver, HarnessSession } from "../contracts/harness-driver.js";
|
|
2
|
+
import type { NativeSession, NativeSessionBackend, NativeSessionBackendDescriptor, NativeSessionRecoveryOptions, OpenNativeSessionInput, PersistedNativeSession } from "../contracts/native-session-backend.js";
|
|
3
|
+
import type { PrpEvent, PrpTerminalState } from "../protocol/replay-contract.js";
|
|
4
|
+
/**
|
|
5
|
+
* Package-owned adapter from the concrete harness driver contract to the
|
|
6
|
+
* normalized session boundary consumed by Paperclip. Provider mechanics stay
|
|
7
|
+
* behind HarnessDriver; the control plane sees only PRP events and results.
|
|
8
|
+
*/
|
|
9
|
+
export declare class HarnessDriverBackend implements NativeSessionBackend {
|
|
10
|
+
#private;
|
|
11
|
+
constructor(driver: HarnessDriver);
|
|
12
|
+
descriptor(): Promise<NativeSessionBackendDescriptor>;
|
|
13
|
+
openSession(input: OpenNativeSessionInput): Promise<NativeSession>;
|
|
14
|
+
recoverSession(snapshot: PersistedNativeSession, options: NativeSessionRecoveryOptions): Promise<{
|
|
15
|
+
recovered: boolean;
|
|
16
|
+
reason: string | undefined;
|
|
17
|
+
session?: undefined;
|
|
18
|
+
} | {
|
|
19
|
+
reason?: undefined;
|
|
20
|
+
recovered: boolean;
|
|
21
|
+
session: HarnessNativeSession;
|
|
22
|
+
}>;
|
|
23
|
+
}
|
|
24
|
+
declare class HarnessNativeSession implements NativeSession {
|
|
25
|
+
#private;
|
|
26
|
+
constructor(input: OpenNativeSessionInput, session: HarnessSession, terminal?: PrpTerminalState | null);
|
|
27
|
+
identity(): import("../index.js").NativeRunIdentity;
|
|
28
|
+
capabilities(): Promise<{
|
|
29
|
+
resume: boolean;
|
|
30
|
+
typedEvents: boolean;
|
|
31
|
+
steering: boolean;
|
|
32
|
+
interruption: boolean;
|
|
33
|
+
structuredResult: boolean;
|
|
34
|
+
read: boolean;
|
|
35
|
+
reconciliation: boolean;
|
|
36
|
+
usage: boolean;
|
|
37
|
+
runtimeRequestResolution: boolean;
|
|
38
|
+
runtimeRequestHandoff: boolean;
|
|
39
|
+
goals: boolean;
|
|
40
|
+
threadLineage: boolean;
|
|
41
|
+
}>;
|
|
42
|
+
attachRun(input: {
|
|
43
|
+
identity: OpenNativeSessionInput["identity"];
|
|
44
|
+
}): Promise<void>;
|
|
45
|
+
events(): AsyncIterable<PrpEvent>;
|
|
46
|
+
startTurn(input: Parameters<HarnessSession["startTurn"]>[0]): Promise<{
|
|
47
|
+
turnId: string;
|
|
48
|
+
effectiveCollaborationMode?: "default" | "plan";
|
|
49
|
+
}>;
|
|
50
|
+
steer(input: {
|
|
51
|
+
turnId: string;
|
|
52
|
+
message: {
|
|
53
|
+
role: "user";
|
|
54
|
+
text: string;
|
|
55
|
+
};
|
|
56
|
+
correlationId?: string;
|
|
57
|
+
}): Promise<void>;
|
|
58
|
+
interrupt(input: {
|
|
59
|
+
turnId?: string;
|
|
60
|
+
reason?: string;
|
|
61
|
+
}): Promise<void>;
|
|
62
|
+
cancel(input: {
|
|
63
|
+
reason: string;
|
|
64
|
+
signal: AbortSignal;
|
|
65
|
+
}): {
|
|
66
|
+
cleanup: Promise<void>;
|
|
67
|
+
};
|
|
68
|
+
resolveRuntimeRequest(input: {
|
|
69
|
+
requestId: string;
|
|
70
|
+
turnId: string;
|
|
71
|
+
resolution: Parameters<NonNullable<HarnessSession["resolveRuntimeRequest"]>>[0]["resolution"];
|
|
72
|
+
}): Promise<void>;
|
|
73
|
+
handoffRuntimeRequest(input: {
|
|
74
|
+
requestId: string;
|
|
75
|
+
turnId: string;
|
|
76
|
+
reason: "durable_handoff";
|
|
77
|
+
signal: AbortSignal;
|
|
78
|
+
}): import("../contracts/harness-driver.js").HarnessRuntimeRequestHandoff;
|
|
79
|
+
result(): Promise<{
|
|
80
|
+
result: {
|
|
81
|
+
[x: string]: unknown;
|
|
82
|
+
artifacts: {
|
|
83
|
+
[x: string]: unknown;
|
|
84
|
+
kind: string;
|
|
85
|
+
ref: string;
|
|
86
|
+
title?: string | undefined;
|
|
87
|
+
}[];
|
|
88
|
+
attentionRequests: {
|
|
89
|
+
[x: string]: unknown;
|
|
90
|
+
kind?: string | undefined;
|
|
91
|
+
ownerClass?: "agent" | "external_system" | "human" | undefined;
|
|
92
|
+
summary?: string | undefined;
|
|
93
|
+
targetAgentId?: string | undefined;
|
|
94
|
+
}[];
|
|
95
|
+
blocker?: {
|
|
96
|
+
[x: string]: unknown;
|
|
97
|
+
owner: {
|
|
98
|
+
[x: string]: unknown;
|
|
99
|
+
kind: "agent" | "external" | "system" | "user";
|
|
100
|
+
name: string;
|
|
101
|
+
};
|
|
102
|
+
reasonCode: string;
|
|
103
|
+
scope: "current_track" | "task_wide";
|
|
104
|
+
unblockAction: string;
|
|
105
|
+
} | undefined;
|
|
106
|
+
completionClaim: {
|
|
107
|
+
[x: string]: unknown;
|
|
108
|
+
contractRevision: string;
|
|
109
|
+
criteria: {
|
|
110
|
+
[x: string]: unknown;
|
|
111
|
+
criterionId: string;
|
|
112
|
+
evidenceRefs: string[];
|
|
113
|
+
explanation?: string | undefined;
|
|
114
|
+
status: "not_satisfied" | "satisfied" | "unknown";
|
|
115
|
+
}[];
|
|
116
|
+
objectiveSatisfied: boolean;
|
|
117
|
+
remainingWork: {
|
|
118
|
+
[x: string]: unknown;
|
|
119
|
+
blocksCompletion: boolean;
|
|
120
|
+
description: string;
|
|
121
|
+
}[];
|
|
122
|
+
};
|
|
123
|
+
continuation?: {
|
|
124
|
+
[x: string]: unknown;
|
|
125
|
+
idempotencyKey: string;
|
|
126
|
+
kind: "delegated_issue" | "monitor" | "response_wake" | "retry" | "same_agent";
|
|
127
|
+
summary: string;
|
|
128
|
+
} | undefined;
|
|
129
|
+
evidence: {
|
|
130
|
+
[x: string]: unknown;
|
|
131
|
+
}[];
|
|
132
|
+
reportedWorkDisposition: "blocked" | "done" | "needs_review" | "yielded";
|
|
133
|
+
schema: "paperclip.run_result.v1";
|
|
134
|
+
summary: string;
|
|
135
|
+
verification: {
|
|
136
|
+
[x: string]: unknown;
|
|
137
|
+
artifactRef?: string | undefined;
|
|
138
|
+
commandOrCheck: string;
|
|
139
|
+
detail?: string | undefined;
|
|
140
|
+
reasonCode?: "budget_exhausted" | "credential_missing" | "dependency_missing" | "environment_unavailable" | "external_service_unavailable" | "other" | "permission_denied" | "policy_restricted" | "tool_unavailable" | undefined;
|
|
141
|
+
status: "failed" | "not_run" | "passed";
|
|
142
|
+
}[];
|
|
143
|
+
};
|
|
144
|
+
terminal: {
|
|
145
|
+
[x: string]: unknown;
|
|
146
|
+
reportedWorkDisposition: "blocked" | "done" | "needs_review" | "yielded";
|
|
147
|
+
runTerminalState: "cancelled" | "failed" | "succeeded";
|
|
148
|
+
schema: "paperclip.prp.terminal.v1";
|
|
149
|
+
statusDecisionId?: string | undefined;
|
|
150
|
+
stopReason?: undefined;
|
|
151
|
+
turnTerminalState: "cancelled" | "completed" | "failed" | "interrupted";
|
|
152
|
+
workAssessmentId?: string | undefined;
|
|
153
|
+
};
|
|
154
|
+
turnId: string;
|
|
155
|
+
} | null>;
|
|
156
|
+
snapshot(): Promise<PersistedNativeSession>;
|
|
157
|
+
usage(): Promise<Record<string, unknown> | null>;
|
|
158
|
+
close(input: {
|
|
159
|
+
reason: string;
|
|
160
|
+
}): Promise<void>;
|
|
161
|
+
}
|
|
162
|
+
export declare function createHarnessDriverBackend(driver: HarnessDriver): NativeSessionBackend;
|
|
163
|
+
export {};
|
|
164
|
+
//# sourceMappingURL=harness-driver-backend.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"harness-driver-backend.d.ts","sourceRoot":"","sources":["../../src/backends/harness-driver-backend.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EAGf,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EACV,aAAa,EACb,oBAAoB,EACpB,8BAA8B,EAC9B,4BAA4B,EAC5B,sBAAsB,EACtB,sBAAsB,EACvB,MAAM,wCAAwC,CAAC;AAChD,OAAO,KAAK,EACV,QAAQ,EACR,gBAAgB,EACjB,MAAM,gCAAgC,CAAC;AAExC;;;;GAIG;AACH,qBAAa,oBAAqB,YAAW,oBAAoB;;IAG/D,YAAY,MAAM,EAAE,aAAa,EAEhC;IAEK,UAAU,IAAI,OAAO,CAAC,8BAA8B,CAAC,CAS1D;IAEK,WAAW,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,aAAa,CAAC,CAqBvE;IAEK,cAAc,CAClB,QAAQ,EAAE,sBAAsB,EAChC,OAAO,EAAE,4BAA4B;;;;;;;;OAqEtC;CACF;AAoBD,cAAM,oBAAqB,YAAW,aAAa;;IAMjD,YACE,KAAK,EAAE,sBAAsB,EAC7B,OAAO,EAAE,cAAc,EACvB,QAAQ,CAAC,EAAE,gBAAgB,GAAG,IAAI,EAKnC;IAED,QAAQ,4CAEP;IAEK,YAAY;;;;;;;;;;;;;OAejB;IAEK,SAAS,CAAC,KAAK,EAAE;QAAE,QAAQ,EAAE,sBAAsB,CAAC,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MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC,CAErD;IAED,KAAK,CAAC,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,iBAE9B;CACF;AAQD,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,aAAa,GAAG,oBAAoB,CAEtF"}
|
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Package-owned adapter from the concrete harness driver contract to the
|
|
3
|
+
* normalized session boundary consumed by Paperclip. Provider mechanics stay
|
|
4
|
+
* behind HarnessDriver; the control plane sees only PRP events and results.
|
|
5
|
+
*/
|
|
6
|
+
export class HarnessDriverBackend {
|
|
7
|
+
#driver;
|
|
8
|
+
constructor(driver) {
|
|
9
|
+
this.#driver = driver;
|
|
10
|
+
}
|
|
11
|
+
async descriptor() {
|
|
12
|
+
const descriptor = await this.#driver.descriptor();
|
|
13
|
+
return {
|
|
14
|
+
kind: "runner",
|
|
15
|
+
name: descriptor.kind,
|
|
16
|
+
version: descriptor.version,
|
|
17
|
+
capabilities: structuredClone(descriptor.capabilities),
|
|
18
|
+
runtimeContextCapabilities: descriptor.runtimeContextCapabilities === undefined ? undefined : structuredClone(descriptor.runtimeContextCapabilities),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
async openSession(input) {
|
|
22
|
+
const session = await this.#driver.openSession({
|
|
23
|
+
runId: input.identity.runId,
|
|
24
|
+
normalizedSessionId: input.identity.sessionId,
|
|
25
|
+
workingDirectory: input.workingDirectory ?? process.cwd(),
|
|
26
|
+
...(input.signal === undefined ? {} : { signal: input.signal }),
|
|
27
|
+
});
|
|
28
|
+
try {
|
|
29
|
+
assertProviderSessionIdentity(session, (await this.#driver.descriptor()).kind, "session.open");
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
await session.close({
|
|
33
|
+
reason: "provider session bootstrap returned an incomplete identity",
|
|
34
|
+
force: true,
|
|
35
|
+
}).catch(() => undefined);
|
|
36
|
+
throw error;
|
|
37
|
+
}
|
|
38
|
+
return new HarnessNativeSession(input, session);
|
|
39
|
+
}
|
|
40
|
+
async recoverSession(snapshot, options) {
|
|
41
|
+
if (this.#driver.recoverSession === undefined) {
|
|
42
|
+
return { recovered: false, reason: "driver does not support recovery" };
|
|
43
|
+
}
|
|
44
|
+
// `null` is a durable "no active turn" checkpoint. Only an omitted legacy
|
|
45
|
+
// field may use the compatibility fallback; nullish coalescing here would
|
|
46
|
+
// otherwise turn the most recent terminal turn back into an active one.
|
|
47
|
+
const activeTurnId = snapshot.activeTurnId === undefined
|
|
48
|
+
? snapshot.terminalTurns?.at(-1)?.turnId ?? null
|
|
49
|
+
: snapshot.activeTurnId;
|
|
50
|
+
const persisted = {
|
|
51
|
+
driverKind: snapshot.driverKind ?? snapshot.backendKind,
|
|
52
|
+
driverSessionId: snapshot.sessionId,
|
|
53
|
+
providerSessionId: snapshot.providerSessionId,
|
|
54
|
+
...(snapshot.providerIdentity === undefined
|
|
55
|
+
? {}
|
|
56
|
+
: { providerIdentity: structuredClone(snapshot.providerIdentity) }),
|
|
57
|
+
...(snapshot.providerRecoveryPolicy === undefined
|
|
58
|
+
? {}
|
|
59
|
+
: { providerRecoveryPolicy: snapshot.providerRecoveryPolicy }),
|
|
60
|
+
runId: snapshot.identity.runId,
|
|
61
|
+
normalizedSessionId: snapshot.identity.sessionId,
|
|
62
|
+
activeTurnId,
|
|
63
|
+
lastSourceSequence: parseCursor(snapshot.cursor),
|
|
64
|
+
...(snapshot.semanticResult === undefined || snapshot.semanticResult === null
|
|
65
|
+
? {}
|
|
66
|
+
: {
|
|
67
|
+
semanticResult: {
|
|
68
|
+
result: snapshot.semanticResult,
|
|
69
|
+
fingerprint: canonicalJson(snapshot.semanticResult),
|
|
70
|
+
turnId: activeTurnId ?? snapshot.terminalTurns?.at(-1)?.turnId ?? "recovered",
|
|
71
|
+
},
|
|
72
|
+
}),
|
|
73
|
+
terminalTurns: snapshot.terminalTurns ?? [],
|
|
74
|
+
pendingRuntimeRequests: snapshot.pendingRuntimeRequests ?? [],
|
|
75
|
+
lineage: snapshot.lineage ?? [],
|
|
76
|
+
};
|
|
77
|
+
const recoveryOptions = {
|
|
78
|
+
signal: options.signal,
|
|
79
|
+
};
|
|
80
|
+
const recovered = await this.#driver.recoverSession(persisted, recoveryOptions);
|
|
81
|
+
if (!recovered.recovered || recovered.session === undefined) {
|
|
82
|
+
return { recovered: false, reason: recovered.reason };
|
|
83
|
+
}
|
|
84
|
+
try {
|
|
85
|
+
assertProviderSessionIdentity(recovered.session, (await this.#driver.descriptor()).kind, "session.recover");
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
await recovered.session.close({
|
|
89
|
+
reason: "provider session recovery returned an incomplete identity",
|
|
90
|
+
force: true,
|
|
91
|
+
}).catch(() => undefined);
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
recovered: true,
|
|
96
|
+
session: new HarnessNativeSession({ identity: snapshot.identity }, recovered.session, snapshot.terminal),
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function assertProviderSessionIdentity(session, provider, stage) {
|
|
101
|
+
const ids = session.ids();
|
|
102
|
+
if (typeof ids.driverSessionId !== "string"
|
|
103
|
+
|| ids.driverSessionId.trim().length === 0
|
|
104
|
+
|| typeof ids.providerSessionId !== "string"
|
|
105
|
+
|| ids.providerSessionId.trim().length === 0) {
|
|
106
|
+
throw new Error(`provider_initialize_protocol_error: provider=${provider} stage=${stage} missing durable provider session identity`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
class HarnessNativeSession {
|
|
110
|
+
#input;
|
|
111
|
+
#session;
|
|
112
|
+
#terminal = null;
|
|
113
|
+
#explicitlyCancelled = false;
|
|
114
|
+
constructor(input, session, terminal) {
|
|
115
|
+
this.#input = structuredClone(input);
|
|
116
|
+
this.#session = session;
|
|
117
|
+
this.#terminal = terminal === undefined ? null : structuredClone(terminal);
|
|
118
|
+
}
|
|
119
|
+
identity() {
|
|
120
|
+
return structuredClone(this.#input.identity);
|
|
121
|
+
}
|
|
122
|
+
async capabilities() {
|
|
123
|
+
return {
|
|
124
|
+
resume: true,
|
|
125
|
+
typedEvents: true,
|
|
126
|
+
steering: this.#session.steer !== undefined,
|
|
127
|
+
interruption: this.#session.interrupt !== undefined,
|
|
128
|
+
structuredResult: true,
|
|
129
|
+
read: this.#session.read !== undefined,
|
|
130
|
+
reconciliation: this.#session.reconcile !== undefined,
|
|
131
|
+
usage: this.#session.usage !== undefined,
|
|
132
|
+
runtimeRequestResolution: this.#session.resolveRuntimeRequest !== undefined,
|
|
133
|
+
runtimeRequestHandoff: this.#session.handoffRuntimeRequest !== undefined,
|
|
134
|
+
goals: this.#session.goal !== undefined,
|
|
135
|
+
threadLineage: this.#session.lineage !== undefined,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
async attachRun(input) {
|
|
139
|
+
const currentIdentity = this.#input.identity;
|
|
140
|
+
if (input.identity.sessionId !== currentIdentity.sessionId
|
|
141
|
+
|| input.identity.companyId !== currentIdentity.companyId
|
|
142
|
+
|| input.identity.issueId !== currentIdentity.issueId
|
|
143
|
+
|| input.identity.agentId !== currentIdentity.agentId) {
|
|
144
|
+
throw new Error("native_session_attach_binding_mismatch");
|
|
145
|
+
}
|
|
146
|
+
if (this.#session.attachRun === undefined) {
|
|
147
|
+
throw new Error("native_session_multi_run_unavailable");
|
|
148
|
+
}
|
|
149
|
+
await this.#session.attachRun({ runId: input.identity.runId });
|
|
150
|
+
this.#input = { ...this.#input, identity: structuredClone(input.identity) };
|
|
151
|
+
this.#terminal = null;
|
|
152
|
+
this.#explicitlyCancelled = false;
|
|
153
|
+
}
|
|
154
|
+
async *events() {
|
|
155
|
+
let sourceInstanceId = null;
|
|
156
|
+
let lastSourceSequence = 0;
|
|
157
|
+
let sawTerminal = false;
|
|
158
|
+
let synthesizedDurableWait = false;
|
|
159
|
+
let streamFailure = null;
|
|
160
|
+
const observedPendingInputs = new Map();
|
|
161
|
+
try {
|
|
162
|
+
for await (const event of this.#session.events()) {
|
|
163
|
+
sourceInstanceId = event.sourceInstanceId;
|
|
164
|
+
lastSourceSequence = Math.max(lastSourceSequence, event.sourceSeq);
|
|
165
|
+
if (event.eventType === "runtime_request.created") {
|
|
166
|
+
const request = plainRecord(event.payload.request);
|
|
167
|
+
if (request?.schema === "paperclip.runtime_request.v2"
|
|
168
|
+
&& request.type === "input"
|
|
169
|
+
&& typeof request.requestId === "string")
|
|
170
|
+
observedPendingInputs.set(request.requestId, structuredClone(request));
|
|
171
|
+
}
|
|
172
|
+
else if (["runtime_request.resolved", "runtime_request.cancelled", "runtime_request.expired"].includes(event.eventType)) {
|
|
173
|
+
const requestId = typeof event.payload.requestId === "string" ? event.payload.requestId : null;
|
|
174
|
+
if (requestId)
|
|
175
|
+
observedPendingInputs.delete(requestId);
|
|
176
|
+
}
|
|
177
|
+
if (event.eventType === "run.terminal") {
|
|
178
|
+
sawTerminal = true;
|
|
179
|
+
this.#terminal = structuredClone(event.payload);
|
|
180
|
+
}
|
|
181
|
+
else if (["turn.completed", "turn.failed", "turn.interrupted", "turn.cancelled"].includes(event.eventType)) {
|
|
182
|
+
sawTerminal = true;
|
|
183
|
+
const snapshot = await this.#session.snapshot();
|
|
184
|
+
const disposition = snapshot.semanticResult?.result.reportedWorkDisposition ?? "yielded";
|
|
185
|
+
this.#terminal = {
|
|
186
|
+
schema: "paperclip.prp.terminal.v1",
|
|
187
|
+
turnTerminalState: event.eventType === "turn.completed" ? "completed"
|
|
188
|
+
: event.eventType === "turn.failed" ? "failed"
|
|
189
|
+
: event.eventType === "turn.interrupted" ? "interrupted"
|
|
190
|
+
: "cancelled",
|
|
191
|
+
runTerminalState: event.eventType === "turn.completed" ? "succeeded" : event.eventType === "turn.failed" ? "failed" : "cancelled",
|
|
192
|
+
reportedWorkDisposition: disposition,
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
yield structuredClone(event);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
catch (error) {
|
|
199
|
+
streamFailure = error;
|
|
200
|
+
}
|
|
201
|
+
// The provider can disappear while its native RPC is awaiting the user.
|
|
202
|
+
// Emit one canonical terminal fact and replace the stream failure with a
|
|
203
|
+
// governed wait; the control plane can materialize the continuation without
|
|
204
|
+
// ever trying to replay the dead provider request.
|
|
205
|
+
if (!sawTerminal && !this.#explicitlyCancelled && sourceInstanceId) {
|
|
206
|
+
const snapshot = await this.#session.snapshot().catch(() => null);
|
|
207
|
+
let governedWaitTurnId;
|
|
208
|
+
for (const request of observedPendingInputs.values()) {
|
|
209
|
+
const sourceSeq = Math.max(lastSourceSequence, snapshot?.lastSourceSequence ?? 0) + 1;
|
|
210
|
+
lastSourceSequence = sourceSeq;
|
|
211
|
+
const requestId = String(request.requestId);
|
|
212
|
+
const turnId = typeof request.turnId === "string" ? request.turnId : undefined;
|
|
213
|
+
governedWaitTurnId ??= turnId;
|
|
214
|
+
const itemId = typeof request.itemId === "string" ? request.itemId : requestId;
|
|
215
|
+
yield {
|
|
216
|
+
schema: "paperclip.prp.event.v1",
|
|
217
|
+
sourceEventId: `${sourceInstanceId}:${this.#input.identity.runId}:${sourceSeq}`,
|
|
218
|
+
sourceSeq,
|
|
219
|
+
sourceInstanceId,
|
|
220
|
+
sourceKind: "runner",
|
|
221
|
+
runId: this.#input.identity.runId,
|
|
222
|
+
normalizedSessionId: this.#input.identity.sessionId,
|
|
223
|
+
...(turnId ? { turnId } : {}),
|
|
224
|
+
itemId,
|
|
225
|
+
eventType: "runtime_request.expired",
|
|
226
|
+
schemaVersion: 1,
|
|
227
|
+
priority: 0,
|
|
228
|
+
emittedAt: new Date().toISOString(),
|
|
229
|
+
payload: {
|
|
230
|
+
requestId,
|
|
231
|
+
...(turnId ? { turnId } : {}),
|
|
232
|
+
itemId,
|
|
233
|
+
requestKind: "runtime",
|
|
234
|
+
reason: "provider_process_lost",
|
|
235
|
+
replayAllowed: false,
|
|
236
|
+
requestType: "input",
|
|
237
|
+
...(plainRecord(request.origin)?.adapter
|
|
238
|
+
? { adapter: plainRecord(request.origin)?.adapter }
|
|
239
|
+
: {}),
|
|
240
|
+
request: structuredClone(request),
|
|
241
|
+
},
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
if (governedWaitTurnId) {
|
|
245
|
+
const sourceSeq = Math.max(lastSourceSequence, snapshot?.lastSourceSequence ?? 0) + 1;
|
|
246
|
+
lastSourceSequence = sourceSeq;
|
|
247
|
+
synthesizedDurableWait = true;
|
|
248
|
+
sawTerminal = true;
|
|
249
|
+
this.#terminal = {
|
|
250
|
+
schema: "paperclip.prp.terminal.v1",
|
|
251
|
+
turnTerminalState: "interrupted",
|
|
252
|
+
runTerminalState: "cancelled",
|
|
253
|
+
reportedWorkDisposition: "yielded",
|
|
254
|
+
};
|
|
255
|
+
yield {
|
|
256
|
+
schema: "paperclip.prp.event.v1",
|
|
257
|
+
sourceEventId: `${sourceInstanceId}:${this.#input.identity.runId}:${sourceSeq}`,
|
|
258
|
+
sourceSeq,
|
|
259
|
+
sourceInstanceId,
|
|
260
|
+
sourceKind: "runner",
|
|
261
|
+
runId: this.#input.identity.runId,
|
|
262
|
+
normalizedSessionId: this.#input.identity.sessionId,
|
|
263
|
+
turnId: governedWaitTurnId,
|
|
264
|
+
eventType: "turn.interrupted",
|
|
265
|
+
schemaVersion: 1,
|
|
266
|
+
priority: 0,
|
|
267
|
+
emittedAt: new Date().toISOString(),
|
|
268
|
+
payload: { status: "interrupted", reason: "provider_process_lost" },
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
if (streamFailure && !synthesizedDurableWait)
|
|
273
|
+
throw streamFailure;
|
|
274
|
+
}
|
|
275
|
+
startTurn(input) {
|
|
276
|
+
return this.#session.startTurn(input);
|
|
277
|
+
}
|
|
278
|
+
steer(input) {
|
|
279
|
+
if (this.#session.steer === undefined)
|
|
280
|
+
throw new Error("steering is unavailable");
|
|
281
|
+
return this.#session.steer(input);
|
|
282
|
+
}
|
|
283
|
+
interrupt(input) {
|
|
284
|
+
if (this.#session.interrupt === undefined)
|
|
285
|
+
throw new Error("interruption is unavailable");
|
|
286
|
+
return this.#session.interrupt(input);
|
|
287
|
+
}
|
|
288
|
+
cancel(input) {
|
|
289
|
+
if (input.signal.aborted) {
|
|
290
|
+
throw input.signal.reason ?? new Error("native session cancellation aborted");
|
|
291
|
+
}
|
|
292
|
+
// This flag is the adapter's synchronous publication boundary. Provider
|
|
293
|
+
// interruption happens afterward as passive cleanup, so a slow or broken
|
|
294
|
+
// transport cannot synthesize or publish new accepted output for the turn.
|
|
295
|
+
this.#explicitlyCancelled = true;
|
|
296
|
+
const interrupt = this.#session.interrupt;
|
|
297
|
+
return {
|
|
298
|
+
cleanup: interrupt === undefined
|
|
299
|
+
? Promise.resolve()
|
|
300
|
+
: Promise.resolve().then(() => interrupt.call(this.#session, {
|
|
301
|
+
reason: input.reason,
|
|
302
|
+
signal: input.signal,
|
|
303
|
+
})),
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
resolveRuntimeRequest(input) {
|
|
307
|
+
if (this.#session.resolveRuntimeRequest === undefined) {
|
|
308
|
+
throw new Error("native_runtime_request_resolution_unavailable");
|
|
309
|
+
}
|
|
310
|
+
return this.#session.resolveRuntimeRequest(input);
|
|
311
|
+
}
|
|
312
|
+
handoffRuntimeRequest(input) {
|
|
313
|
+
if (this.#session.handoffRuntimeRequest === undefined) {
|
|
314
|
+
throw new Error("native_runtime_request_handoff_unavailable");
|
|
315
|
+
}
|
|
316
|
+
return this.#session.handoffRuntimeRequest(input);
|
|
317
|
+
}
|
|
318
|
+
async result() {
|
|
319
|
+
const snapshot = await this.#session.snapshot();
|
|
320
|
+
if (snapshot.semanticResult === undefined || snapshot.semanticResult === null) {
|
|
321
|
+
return null;
|
|
322
|
+
}
|
|
323
|
+
if (this.#terminal === null) {
|
|
324
|
+
return null;
|
|
325
|
+
}
|
|
326
|
+
return {
|
|
327
|
+
result: structuredClone(snapshot.semanticResult.result),
|
|
328
|
+
terminal: structuredClone(this.#terminal),
|
|
329
|
+
turnId: snapshot.semanticResult.turnId,
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
async snapshot() {
|
|
333
|
+
const snapshot = await this.#session.snapshot();
|
|
334
|
+
return {
|
|
335
|
+
backendKind: "runner",
|
|
336
|
+
driverKind: snapshot.driverKind,
|
|
337
|
+
sessionId: snapshot.driverSessionId,
|
|
338
|
+
identity: structuredClone(this.#input.identity),
|
|
339
|
+
providerSessionId: snapshot.providerSessionId,
|
|
340
|
+
...(snapshot.providerIdentity === undefined
|
|
341
|
+
? {}
|
|
342
|
+
: { providerIdentity: structuredClone(snapshot.providerIdentity) }),
|
|
343
|
+
...(snapshot.providerRecoveryPolicy === undefined
|
|
344
|
+
? {}
|
|
345
|
+
: { providerRecoveryPolicy: snapshot.providerRecoveryPolicy }),
|
|
346
|
+
cursor: snapshot.lastSourceSequence === undefined
|
|
347
|
+
? null
|
|
348
|
+
: String(snapshot.lastSourceSequence),
|
|
349
|
+
semanticResult: snapshot.semanticResult?.result ?? null,
|
|
350
|
+
terminal: this.#terminal,
|
|
351
|
+
// Harness snapshots use an explicit null to record a settled turn. Keep
|
|
352
|
+
// the semantic-result fallback solely for legacy snapshots that omitted
|
|
353
|
+
// activeTurnId, or a later recovery can replay the terminal turn.
|
|
354
|
+
activeTurnId: snapshot.activeTurnId === undefined
|
|
355
|
+
? snapshot.semanticResult?.turnId ?? null
|
|
356
|
+
: snapshot.activeTurnId,
|
|
357
|
+
terminalTurns: snapshot.terminalTurns ?? [],
|
|
358
|
+
pendingRuntimeRequests: snapshot.pendingRuntimeRequests ?? [],
|
|
359
|
+
lineage: snapshot.lineage ?? [],
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
async usage() {
|
|
363
|
+
return this.#session.usage?.() ?? null;
|
|
364
|
+
}
|
|
365
|
+
close(input) {
|
|
366
|
+
return this.#session.close(input);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
function plainRecord(value) {
|
|
370
|
+
return typeof value === "object" && value !== null && !Array.isArray(value)
|
|
371
|
+
? value
|
|
372
|
+
: null;
|
|
373
|
+
}
|
|
374
|
+
export function createHarnessDriverBackend(driver) {
|
|
375
|
+
return new HarnessDriverBackend(driver);
|
|
376
|
+
}
|
|
377
|
+
function parseCursor(cursor) {
|
|
378
|
+
if (cursor === undefined || cursor === null || cursor === "")
|
|
379
|
+
return undefined;
|
|
380
|
+
const parsed = Number(cursor);
|
|
381
|
+
return Number.isSafeInteger(parsed) && parsed >= 0 ? parsed : undefined;
|
|
382
|
+
}
|
|
383
|
+
function canonicalJson(value) {
|
|
384
|
+
if (Array.isArray(value))
|
|
385
|
+
return `[${value.map(canonicalJson).join(",")}]`;
|
|
386
|
+
if (typeof value === "object" && value !== null) {
|
|
387
|
+
const record = value;
|
|
388
|
+
return `{${Object.keys(record)
|
|
389
|
+
.sort()
|
|
390
|
+
.map((key) => `${JSON.stringify(key)}:${canonicalJson(record[key])}`)
|
|
391
|
+
.join(",")}}`;
|
|
392
|
+
}
|
|
393
|
+
return JSON.stringify(value) ?? "undefined";
|
|
394
|
+
}
|
|
395
|
+
//# sourceMappingURL=harness-driver-backend.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"harness-driver-backend.js","sourceRoot":"","sources":["../../src/backends/harness-driver-backend.ts"],"names":[],"mappings":"AAmBA;;;;GAIG;AACH,MAAM,OAAO,oBAAoB;IACtB,OAAO,CAAgB;IAEhC,YAAY,MAAqB;QAC/B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,UAAU;QACd,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;QACnD,OAAO;YACL,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,UAAU,CAAC,IAAI;YACrB,OAAO,EAA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C;AAED,SAAS,aAAa,CAAC,KAAc;IACnC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,KAAK,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IAC3E,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,MAAM,MAAM,GAAG,KAAgC,CAAC;QAChD,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;aAC3B,IAAI,EAAE;aACN,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;aACpE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IAClB,CAAC;IACD,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,WAAW,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { NativeExecutionInput } from "../contracts/native-execution.js";
|
|
2
|
+
export declare function nativeSystemInstructions(input: NativeExecutionInput): string;
|
|
3
|
+
export declare function nativeTaskConstraints(input: NativeExecutionInput): string[];
|
|
4
|
+
//# sourceMappingURL=runtime-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-context.d.ts","sourceRoot":"","sources":["../../src/backends/runtime-context.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAG7E,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,oBAAoB,GAAG,MAAM,CAkB5E;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,oBAAoB,GAAG,MAAM,EAAE,CAe3E"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { readFileSync, realpathSync } from "node:fs";
|
|
2
|
+
import { isAbsolute, relative, resolve, sep } from "node:path";
|
|
3
|
+
import { CODEX_SKILLLESS_BASE_INSTRUCTIONS } from "../contracts/codex.js";
|
|
4
|
+
import { composeNativeSystemInstructions } from "../contracts/runtime-context.js";
|
|
5
|
+
export function nativeSystemInstructions(input) {
|
|
6
|
+
if (!("runtimeContext" in input))
|
|
7
|
+
return CODEX_SKILLLESS_BASE_INSTRUCTIONS;
|
|
8
|
+
const configuredRoot = resolve(input.runtimeContext.instructions.bundle.rootPath);
|
|
9
|
+
const bundleRoot = realpathSync(configuredRoot);
|
|
10
|
+
const entryPath = realpathSync(resolve(configuredRoot, input.runtimeContext.instructions.entryPath));
|
|
11
|
+
const pathFromRoot = relative(bundleRoot, entryPath);
|
|
12
|
+
if (pathFromRoot === ".."
|
|
13
|
+
|| pathFromRoot.startsWith(`..${sep}`)
|
|
14
|
+
|| isAbsolute(pathFromRoot)) {
|
|
15
|
+
throw new Error("native_runtime_context_entry_outside_bundle");
|
|
16
|
+
}
|
|
17
|
+
const entry = readFileSync(entryPath, "utf8");
|
|
18
|
+
return composeNativeSystemInstructions(input.runtimeContext, entry);
|
|
19
|
+
}
|
|
20
|
+
export function nativeTaskConstraints(input) {
|
|
21
|
+
const finalResponseConstraint = "Write the complete user-facing final response exactly once before invoking paperclip_finish or paperclip_block. Treat that semantic completion tool as the last action and do not emit a trailing acknowledgement.";
|
|
22
|
+
if (!("runtimeContext" in input)) {
|
|
23
|
+
return [
|
|
24
|
+
"Do not discover or invoke skills.",
|
|
25
|
+
"Do not call a control-plane API.",
|
|
26
|
+
finalResponseConstraint,
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
return [
|
|
30
|
+
"Use only the assigned skills and provider-native tools.",
|
|
31
|
+
"Use Paperclip semantic tools for coordination and finalization.",
|
|
32
|
+
finalResponseConstraint,
|
|
33
|
+
];
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=runtime-context.js.map
|
|
@@ -0,0 +1 @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