stageflow 0.1.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/LICENSE +21 -0
- package/README.md +56 -0
- package/dist/agent/activity.d.ts +76 -0
- package/dist/agent/activity.js +89 -0
- package/dist/agent/activityObserver.d.ts +17 -0
- package/dist/agent/activityObserver.js +66 -0
- package/dist/agent/cursorExtension.d.ts +12 -0
- package/dist/agent/cursorExtension.js +88 -0
- package/dist/agent/cursorProvider.d.ts +14 -0
- package/dist/agent/cursorProvider.js +139 -0
- package/dist/agent/fakeAgent.d.ts +29 -0
- package/dist/agent/fakeAgent.js +295 -0
- package/dist/agent/oauthSessionManager.d.ts +33 -0
- package/dist/agent/oauthSessionManager.js +214 -0
- package/dist/agent/piAdapter.d.ts +128 -0
- package/dist/agent/piAdapter.js +967 -0
- package/dist/agent/port.d.ts +63 -0
- package/dist/agent/port.js +46 -0
- package/dist/agent/providerAuth.d.ts +101 -0
- package/dist/agent/providerAuth.js +282 -0
- package/dist/agent/providerSupport.d.ts +28 -0
- package/dist/agent/providerSupport.js +19 -0
- package/dist/cli/providersCommand.d.ts +11 -0
- package/dist/cli/providersCommand.js +275 -0
- package/dist/cli/terminalAuthInteraction.d.ts +8 -0
- package/dist/cli/terminalAuthInteraction.js +65 -0
- package/dist/cli/terminalSecret.d.ts +2 -0
- package/dist/cli/terminalSecret.js +67 -0
- package/dist/cli/validateCommand.d.ts +11 -0
- package/dist/cli/validateCommand.js +81 -0
- package/dist/cli/validateOutput.d.ts +8 -0
- package/dist/cli/validateOutput.js +75 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +273 -0
- package/dist/config/createPipeline.d.ts +31 -0
- package/dist/config/createPipeline.js +255 -0
- package/dist/config/createStage.d.ts +25 -0
- package/dist/config/createStage.js +181 -0
- package/dist/config/listConfig.d.ts +33 -0
- package/dist/config/listConfig.js +195 -0
- package/dist/config/listExtensions.d.ts +26 -0
- package/dist/config/listExtensions.js +50 -0
- package/dist/config/listSkills.d.ts +29 -0
- package/dist/config/listSkills.js +55 -0
- package/dist/config/loadOutcome.d.ts +27 -0
- package/dist/config/loadOutcome.js +6 -0
- package/dist/config/loadPipeline.d.ts +25 -0
- package/dist/config/loadPipeline.js +196 -0
- package/dist/config/loadStage.d.ts +4 -0
- package/dist/config/loadStage.js +127 -0
- package/dist/config/loadTask.d.ts +7 -0
- package/dist/config/loadTask.js +69 -0
- package/dist/config/readYamlObject.d.ts +1 -0
- package/dist/config/readYamlObject.js +5 -0
- package/dist/config/resolvePipelineDag.d.ts +12 -0
- package/dist/config/resolvePipelineDag.js +282 -0
- package/dist/config/validateCatalog.d.ts +36 -0
- package/dist/config/validateCatalog.js +322 -0
- package/dist/envelope/check.d.ts +3 -0
- package/dist/envelope/check.js +52 -0
- package/dist/envelope/payloadSchema.d.ts +10 -0
- package/dist/envelope/payloadSchema.js +91 -0
- package/dist/hitl/qaTrail.d.ts +31 -0
- package/dist/hitl/qaTrail.js +65 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +7 -0
- package/dist/mcp/projectRun.d.ts +37 -0
- package/dist/mcp/projectRun.js +57 -0
- package/dist/mcp/readArtifact.d.ts +2 -0
- package/dist/mcp/readArtifact.js +46 -0
- package/dist/mcp/server.d.ts +7 -0
- package/dist/mcp/server.js +26 -0
- package/dist/mcp/tools.d.ts +9 -0
- package/dist/mcp/tools.js +96 -0
- package/dist/package-meta.d.ts +1 -0
- package/dist/package-meta.js +1 -0
- package/dist/prompt/priorEnvelope.d.ts +2 -0
- package/dist/prompt/priorEnvelope.js +5 -0
- package/dist/runstore/catalog.d.ts +8 -0
- package/dist/runstore/catalog.js +16 -0
- package/dist/runstore/createStore.d.ts +15 -0
- package/dist/runstore/createStore.js +23 -0
- package/dist/runstore/disk/DiskRunStore.d.ts +30 -0
- package/dist/runstore/disk/DiskRunStore.js +238 -0
- package/dist/runstore/disk/catalogHelpers.d.ts +11 -0
- package/dist/runstore/disk/catalogHelpers.js +102 -0
- package/dist/runstore/layout.d.ts +22 -0
- package/dist/runstore/layout.js +58 -0
- package/dist/runstore/paths.d.ts +7 -0
- package/dist/runstore/paths.js +60 -0
- package/dist/runstore/pipelineDagSnapshot.d.ts +5 -0
- package/dist/runstore/pipelineDagSnapshot.js +43 -0
- package/dist/runstore/port.d.ts +146 -0
- package/dist/runstore/port.js +28 -0
- package/dist/runstore/runProjection.d.ts +6 -0
- package/dist/runstore/runProjection.js +102 -0
- package/dist/runstore/sqlite/SqliteRunStore.d.ts +48 -0
- package/dist/runstore/sqlite/SqliteRunStore.js +460 -0
- package/dist/runstore/sqlite/migrateFromDisk.d.ts +5 -0
- package/dist/runstore/sqlite/migrateFromDisk.js +108 -0
- package/dist/runstore/sqlite/schema.d.ts +1 -0
- package/dist/runstore/sqlite/schema.js +59 -0
- package/dist/runstore/stageExecution.d.ts +13 -0
- package/dist/runstore/stageExecution.js +22 -0
- package/dist/runstore/stageSnapshot.d.ts +2 -0
- package/dist/runstore/stageSnapshot.js +46 -0
- package/dist/runstore/syntheticStageSnapshot.d.ts +2 -0
- package/dist/runstore/syntheticStageSnapshot.js +10 -0
- package/dist/runstore/trackProjection.d.ts +7 -0
- package/dist/runstore/trackProjection.js +94 -0
- package/dist/runstore/workspaceLayout.d.ts +31 -0
- package/dist/runstore/workspaceLayout.js +172 -0
- package/dist/runtime/answerResume.d.ts +16 -0
- package/dist/runtime/answerResume.js +22 -0
- package/dist/runtime/credentialBinding.d.ts +16 -0
- package/dist/runtime/credentialBinding.js +80 -0
- package/dist/runtime/dagTraversal.d.ts +3 -0
- package/dist/runtime/dagTraversal.js +26 -0
- package/dist/runtime/envelopeRouting.d.ts +20 -0
- package/dist/runtime/envelopeRouting.js +59 -0
- package/dist/runtime/hitlSeams.d.ts +38 -0
- package/dist/runtime/hitlSeams.js +2 -0
- package/dist/runtime/pipelineRunner.d.ts +77 -0
- package/dist/runtime/pipelineRunner.js +141 -0
- package/dist/runtime/pipelineScheduler.d.ts +90 -0
- package/dist/runtime/pipelineScheduler.js +494 -0
- package/dist/runtime/pipelineValidationError.d.ts +6 -0
- package/dist/runtime/pipelineValidationError.js +8 -0
- package/dist/runtime/resumeReconstruct.d.ts +33 -0
- package/dist/runtime/resumeReconstruct.js +144 -0
- package/dist/runtime/runManager.d.ts +129 -0
- package/dist/runtime/runManager.js +818 -0
- package/dist/runtime/runRetryCoordinator.d.ts +85 -0
- package/dist/runtime/runRetryCoordinator.js +372 -0
- package/dist/runtime/settingsFile.d.ts +17 -0
- package/dist/runtime/settingsFile.js +88 -0
- package/dist/runtime/stageAttemptBootstrap.d.ts +40 -0
- package/dist/runtime/stageAttemptBootstrap.js +82 -0
- package/dist/runtime/stageAttemptContext.d.ts +11 -0
- package/dist/runtime/stageAttemptContext.js +26 -0
- package/dist/runtime/stageConcurrency.d.ts +10 -0
- package/dist/runtime/stageConcurrency.js +51 -0
- package/dist/runtime/stageHitl.d.ts +95 -0
- package/dist/runtime/stageHitl.js +198 -0
- package/dist/runtime/stageProcessLauncher.d.ts +45 -0
- package/dist/runtime/stageProcessLauncher.js +199 -0
- package/dist/runtime/stageRecovery.d.ts +10 -0
- package/dist/runtime/stageRecovery.js +43 -0
- package/dist/runtime/stageRoots.d.ts +22 -0
- package/dist/runtime/stageRoots.js +93 -0
- package/dist/runtime/stageRunner.d.ts +59 -0
- package/dist/runtime/stageRunner.js +221 -0
- package/dist/runtime/stageWorker.d.ts +6 -0
- package/dist/runtime/stageWorker.js +109 -0
- package/dist/runtime/stageWorkerProtocol.d.ts +27 -0
- package/dist/runtime/stageWorkerProtocol.js +16 -0
- package/dist/runtime/taskInput.d.ts +15 -0
- package/dist/runtime/taskInput.js +38 -0
- package/dist/server/http.d.ts +31 -0
- package/dist/server/http.js +561 -0
- package/dist/server/providerRoutes.d.ts +15 -0
- package/dist/server/providerRoutes.js +186 -0
- package/dist/tools/askOperator.d.ts +185 -0
- package/dist/tools/askOperator.js +409 -0
- package/dist/tools/emitStageEnvelope.d.ts +42 -0
- package/dist/tools/emitStageEnvelope.js +61 -0
- package/dist/tools/writeStageArtifact.d.ts +26 -0
- package/dist/tools/writeStageArtifact.js +103 -0
- package/dist/types/envelope.d.ts +12 -0
- package/dist/types/envelope.js +6 -0
- package/dist/types/pipeline.d.ts +25 -0
- package/dist/types/pipeline.js +1 -0
- package/dist/types/stage.d.ts +12 -0
- package/dist/types/stage.js +6 -0
- package/dist/types/task.d.ts +7 -0
- package/dist/types/task.js +1 -0
- package/dist/ui/assets/index-Cry0Tpfx.js +118 -0
- package/dist/ui/assets/index-DCsDopak.css +1 -0
- package/dist/ui/index.html +21 -0
- package/package.json +72 -0
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { defaultContext, detectPiHome, getAuthStatus, listProviders, loginWithApiKey, logoutProvider, ProviderAuthError, } from "../agent/providerAuth.js";
|
|
2
|
+
import { answerLoginSession, cancelLoginSession, getLoginSession, startOAuthLoginSession, } from "../agent/oauthSessionManager.js";
|
|
3
|
+
export function providerAuthErrorBody(err) {
|
|
4
|
+
if (err instanceof ProviderAuthError) {
|
|
5
|
+
return { status: err.status, body: { error: err.message } };
|
|
6
|
+
}
|
|
7
|
+
return {
|
|
8
|
+
status: 500,
|
|
9
|
+
body: { error: "Provider auth operation failed" },
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export async function handleProviderRoutes(req, res, ctx) {
|
|
13
|
+
const { cwd, readJsonBody, json } = ctx;
|
|
14
|
+
const authCtx = ctx.providerAuthContext ?? defaultContext;
|
|
15
|
+
const method = req.method ?? "GET";
|
|
16
|
+
const rawUrl = req.url ?? "/";
|
|
17
|
+
const pathname = new URL(rawUrl, "http://localhost").pathname;
|
|
18
|
+
if (method === "GET" && pathname === "/api/providers/detect") {
|
|
19
|
+
try {
|
|
20
|
+
json(res, 200, detectPiHome(cwd));
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
const mapped = providerAuthErrorBody(err);
|
|
24
|
+
json(res, mapped.status, mapped.body);
|
|
25
|
+
}
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
if (method === "GET" && pathname === "/api/providers") {
|
|
29
|
+
try {
|
|
30
|
+
json(res, 200, await listProviders(cwd, authCtx));
|
|
31
|
+
}
|
|
32
|
+
catch (err) {
|
|
33
|
+
const mapped = providerAuthErrorBody(err);
|
|
34
|
+
json(res, mapped.status, mapped.body);
|
|
35
|
+
}
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
const providerAuthMatch = pathname.match(/^\/api\/providers\/([^/]+)\/auth$/);
|
|
39
|
+
if (method === "GET" && providerAuthMatch) {
|
|
40
|
+
const providerId = decodeURIComponent(providerAuthMatch[1] ?? "");
|
|
41
|
+
try {
|
|
42
|
+
json(res, 200, {
|
|
43
|
+
provider: await getAuthStatus(cwd, providerId, authCtx),
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
const mapped = providerAuthErrorBody(err);
|
|
48
|
+
json(res, mapped.status, mapped.body);
|
|
49
|
+
}
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
const providerLoginMatch = pathname.match(/^\/api\/providers\/([^/]+)\/login$/);
|
|
53
|
+
if (method === "POST" && providerLoginMatch) {
|
|
54
|
+
const providerId = decodeURIComponent(providerLoginMatch[1] ?? "");
|
|
55
|
+
let body;
|
|
56
|
+
try {
|
|
57
|
+
body = await readJsonBody(req);
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
json(res, 400, { error: "Invalid JSON body" });
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
const record = body !== null && typeof body === "object" && !Array.isArray(body)
|
|
64
|
+
? body
|
|
65
|
+
: {};
|
|
66
|
+
const authType = record.authType;
|
|
67
|
+
if (authType === "oauth") {
|
|
68
|
+
try {
|
|
69
|
+
const session = await startOAuthLoginSession(cwd, providerId, authCtx);
|
|
70
|
+
json(res, 200, { ok: true, session });
|
|
71
|
+
}
|
|
72
|
+
catch (err) {
|
|
73
|
+
const mapped = providerAuthErrorBody(err);
|
|
74
|
+
json(res, mapped.status, mapped.body);
|
|
75
|
+
}
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
if (authType !== "api_key") {
|
|
79
|
+
json(res, 400, { error: 'authType must be "api_key" or "oauth"' });
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
const apiKey = record.apiKey;
|
|
83
|
+
if (typeof apiKey !== "string" || apiKey.trim().length === 0) {
|
|
84
|
+
json(res, 400, { error: "apiKey is required" });
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
try {
|
|
88
|
+
const provider = await loginWithApiKey(cwd, providerId, apiKey, authCtx);
|
|
89
|
+
json(res, 200, { ok: true, provider });
|
|
90
|
+
}
|
|
91
|
+
catch (err) {
|
|
92
|
+
const mapped = providerAuthErrorBody(err);
|
|
93
|
+
json(res, mapped.status, mapped.body);
|
|
94
|
+
}
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
const providerLoginSessionMatch = pathname.match(/^\/api\/providers\/([^/]+)\/login\/([^/]+)(?:\/(answer|cancel))?$/);
|
|
98
|
+
if (providerLoginSessionMatch) {
|
|
99
|
+
const providerId = decodeURIComponent(providerLoginSessionMatch[1] ?? "");
|
|
100
|
+
const sessionId = decodeURIComponent(providerLoginSessionMatch[2] ?? "");
|
|
101
|
+
const action = providerLoginSessionMatch[3];
|
|
102
|
+
if (method === "GET" && action === undefined) {
|
|
103
|
+
const session = getLoginSession(sessionId);
|
|
104
|
+
if (!session || session.providerId !== providerId) {
|
|
105
|
+
json(res, 404, { error: "Login session not found" });
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
json(res, 200, { session });
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
if (method === "POST" && action === "answer") {
|
|
112
|
+
let body;
|
|
113
|
+
try {
|
|
114
|
+
body = await readJsonBody(req);
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
json(res, 400, { error: "Invalid JSON body" });
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
const record = body !== null && typeof body === "object" && !Array.isArray(body)
|
|
121
|
+
? body
|
|
122
|
+
: {};
|
|
123
|
+
const value = record.value;
|
|
124
|
+
if (typeof value !== "string") {
|
|
125
|
+
json(res, 400, { error: "value is required" });
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
try {
|
|
129
|
+
const existing = getLoginSession(sessionId);
|
|
130
|
+
if (!existing || existing.providerId !== providerId) {
|
|
131
|
+
json(res, 404, { error: "Login session not found" });
|
|
132
|
+
return true;
|
|
133
|
+
}
|
|
134
|
+
const session = answerLoginSession(sessionId, value);
|
|
135
|
+
json(res, 200, { ok: true, session });
|
|
136
|
+
}
|
|
137
|
+
catch (err) {
|
|
138
|
+
const mapped = providerAuthErrorBody(err);
|
|
139
|
+
json(res, mapped.status, mapped.body);
|
|
140
|
+
}
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
if (method === "POST" && action === "cancel") {
|
|
144
|
+
try {
|
|
145
|
+
await readJsonBody(req);
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
// empty body ok
|
|
149
|
+
}
|
|
150
|
+
try {
|
|
151
|
+
const existing = getLoginSession(sessionId);
|
|
152
|
+
if (!existing || existing.providerId !== providerId) {
|
|
153
|
+
json(res, 404, { error: "Login session not found" });
|
|
154
|
+
return true;
|
|
155
|
+
}
|
|
156
|
+
const session = cancelLoginSession(sessionId);
|
|
157
|
+
json(res, 200, { ok: true, session });
|
|
158
|
+
}
|
|
159
|
+
catch (err) {
|
|
160
|
+
const mapped = providerAuthErrorBody(err);
|
|
161
|
+
json(res, mapped.status, mapped.body);
|
|
162
|
+
}
|
|
163
|
+
return true;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
const providerLogoutMatch = pathname.match(/^\/api\/providers\/([^/]+)\/logout$/);
|
|
167
|
+
if (method === "POST" && providerLogoutMatch) {
|
|
168
|
+
const providerId = decodeURIComponent(providerLogoutMatch[1] ?? "");
|
|
169
|
+
try {
|
|
170
|
+
await readJsonBody(req);
|
|
171
|
+
}
|
|
172
|
+
catch {
|
|
173
|
+
// empty body ok
|
|
174
|
+
}
|
|
175
|
+
try {
|
|
176
|
+
const provider = await logoutProvider(cwd, providerId, authCtx);
|
|
177
|
+
json(res, 200, { ok: true, provider });
|
|
178
|
+
}
|
|
179
|
+
catch (err) {
|
|
180
|
+
const mapped = providerAuthErrorBody(err);
|
|
181
|
+
json(res, mapped.status, mapped.body);
|
|
182
|
+
}
|
|
183
|
+
return true;
|
|
184
|
+
}
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
export declare class AskOperatorError extends Error {
|
|
3
|
+
constructor(message: string);
|
|
4
|
+
}
|
|
5
|
+
export declare const ASK_OPERATOR_KINDS: readonly ["free_text", "confirm", "multi_question", "artifact_backed"];
|
|
6
|
+
export type AskOperatorKind = (typeof ASK_OPERATOR_KINDS)[number];
|
|
7
|
+
export type SubQuestionKind = "free_text" | "confirm";
|
|
8
|
+
export type FreeTextPromptParams = {
|
|
9
|
+
kind: "free_text";
|
|
10
|
+
message: string;
|
|
11
|
+
id?: string;
|
|
12
|
+
};
|
|
13
|
+
export type ConfirmPromptParams = {
|
|
14
|
+
kind: "confirm";
|
|
15
|
+
message: string;
|
|
16
|
+
id?: string;
|
|
17
|
+
};
|
|
18
|
+
export type MultiQuestionItemParams = {
|
|
19
|
+
kind: SubQuestionKind;
|
|
20
|
+
message: string;
|
|
21
|
+
id?: string;
|
|
22
|
+
};
|
|
23
|
+
export type MultiQuestionPromptParams = {
|
|
24
|
+
kind: "multi_question";
|
|
25
|
+
questions: MultiQuestionItemParams[];
|
|
26
|
+
id?: string;
|
|
27
|
+
};
|
|
28
|
+
export type ArtifactBackedPromptParams = {
|
|
29
|
+
kind: "artifact_backed";
|
|
30
|
+
message: string;
|
|
31
|
+
artifacts: string[];
|
|
32
|
+
id?: string;
|
|
33
|
+
};
|
|
34
|
+
export type AskOperatorParams = FreeTextPromptParams | ConfirmPromptParams | MultiQuestionPromptParams | ArtifactBackedPromptParams;
|
|
35
|
+
export type MultiQuestionItem = {
|
|
36
|
+
kind: SubQuestionKind;
|
|
37
|
+
message: string;
|
|
38
|
+
id: string;
|
|
39
|
+
};
|
|
40
|
+
export type AskOperatorPrompt = {
|
|
41
|
+
kind: "free_text";
|
|
42
|
+
message: string;
|
|
43
|
+
id: string;
|
|
44
|
+
} | {
|
|
45
|
+
kind: "confirm";
|
|
46
|
+
message: string;
|
|
47
|
+
id: string;
|
|
48
|
+
} | {
|
|
49
|
+
kind: "multi_question";
|
|
50
|
+
id: string;
|
|
51
|
+
questions: MultiQuestionItem[];
|
|
52
|
+
} | {
|
|
53
|
+
kind: "artifact_backed";
|
|
54
|
+
message: string;
|
|
55
|
+
artifacts: string[];
|
|
56
|
+
id: string;
|
|
57
|
+
};
|
|
58
|
+
export type Decision = "accept" | "reject";
|
|
59
|
+
export type FreeTextAnswerPayload = {
|
|
60
|
+
kind: "free_text";
|
|
61
|
+
text: string;
|
|
62
|
+
};
|
|
63
|
+
export type ConfirmAnswerPayload = {
|
|
64
|
+
kind: "confirm";
|
|
65
|
+
decision: Decision;
|
|
66
|
+
text?: string;
|
|
67
|
+
};
|
|
68
|
+
export type FreeTextOrConfirmPayload = FreeTextAnswerPayload | ConfirmAnswerPayload;
|
|
69
|
+
export type AskOperatorAnswer = {
|
|
70
|
+
promptId: string;
|
|
71
|
+
kind: "free_text";
|
|
72
|
+
text: string;
|
|
73
|
+
} | {
|
|
74
|
+
promptId: string;
|
|
75
|
+
kind: "confirm";
|
|
76
|
+
decision: Decision;
|
|
77
|
+
text?: string;
|
|
78
|
+
} | {
|
|
79
|
+
promptId: string;
|
|
80
|
+
kind: "artifact_backed";
|
|
81
|
+
decision: Decision;
|
|
82
|
+
text?: string;
|
|
83
|
+
} | {
|
|
84
|
+
promptId: string;
|
|
85
|
+
kind: "multi_question";
|
|
86
|
+
answers: Record<string, FreeTextOrConfirmPayload>;
|
|
87
|
+
};
|
|
88
|
+
export declare const askOperatorParamsSchema: Type.TUnion<[Type.TObject<{
|
|
89
|
+
kind: Type.TLiteral<"free_text">;
|
|
90
|
+
message: Type.TString;
|
|
91
|
+
id: Type.TOptional<Type.TString>;
|
|
92
|
+
}>, Type.TObject<{
|
|
93
|
+
kind: Type.TLiteral<"confirm">;
|
|
94
|
+
message: Type.TString;
|
|
95
|
+
id: Type.TOptional<Type.TString>;
|
|
96
|
+
}>, Type.TObject<{
|
|
97
|
+
kind: Type.TLiteral<"multi_question">;
|
|
98
|
+
questions: Type.TArray<Type.TObject<{
|
|
99
|
+
kind: Type.TUnion<[Type.TLiteral<"free_text">, Type.TLiteral<"confirm">]>;
|
|
100
|
+
message: Type.TString;
|
|
101
|
+
id: Type.TOptional<Type.TString>;
|
|
102
|
+
}>>;
|
|
103
|
+
id: Type.TOptional<Type.TString>;
|
|
104
|
+
}>, Type.TObject<{
|
|
105
|
+
kind: Type.TLiteral<"artifact_backed">;
|
|
106
|
+
message: Type.TString;
|
|
107
|
+
artifacts: Type.TArray<Type.TString>;
|
|
108
|
+
id: Type.TOptional<Type.TString>;
|
|
109
|
+
}>]>;
|
|
110
|
+
export declare const askOperatorAnswerSchema: Type.TUnion<[Type.TObject<{
|
|
111
|
+
promptId: Type.TString;
|
|
112
|
+
kind: Type.TLiteral<"free_text">;
|
|
113
|
+
text: Type.TString;
|
|
114
|
+
}>, Type.TObject<{
|
|
115
|
+
promptId: Type.TString;
|
|
116
|
+
kind: Type.TLiteral<"confirm">;
|
|
117
|
+
decision: Type.TUnion<[Type.TLiteral<"accept">, Type.TLiteral<"reject">]>;
|
|
118
|
+
text: Type.TOptional<Type.TString>;
|
|
119
|
+
}>, Type.TObject<{
|
|
120
|
+
promptId: Type.TString;
|
|
121
|
+
kind: Type.TLiteral<"artifact_backed">;
|
|
122
|
+
decision: Type.TUnion<[Type.TLiteral<"accept">, Type.TLiteral<"reject">]>;
|
|
123
|
+
text: Type.TOptional<Type.TString>;
|
|
124
|
+
}>, Type.TObject<{
|
|
125
|
+
promptId: Type.TString;
|
|
126
|
+
kind: Type.TLiteral<"multi_question">;
|
|
127
|
+
answers: Type.TRecord<"^.*$", Type.TUnion<[Type.TObject<{
|
|
128
|
+
kind: Type.TLiteral<"free_text">;
|
|
129
|
+
text: Type.TString;
|
|
130
|
+
}>, Type.TObject<{
|
|
131
|
+
kind: Type.TLiteral<"confirm">;
|
|
132
|
+
decision: Type.TUnion<[Type.TLiteral<"accept">, Type.TLiteral<"reject">]>;
|
|
133
|
+
text: Type.TOptional<Type.TString>;
|
|
134
|
+
}>]>>;
|
|
135
|
+
}>]>;
|
|
136
|
+
export declare function parseAskOperatorParams(value: unknown): AskOperatorParams;
|
|
137
|
+
export declare function normalizePromptIds(params: AskOperatorParams): AskOperatorPrompt;
|
|
138
|
+
export declare function parseAskOperatorAnswer(value: unknown): AskOperatorAnswer;
|
|
139
|
+
export declare function assertAnswerMatchesPrompt(prompt: AskOperatorPrompt, answer: AskOperatorAnswer): void;
|
|
140
|
+
export declare const parsePrompt: typeof parseAskOperatorParams;
|
|
141
|
+
export declare const parseAnswer: typeof parseAskOperatorAnswer;
|
|
142
|
+
export type AskOperatorWaitBridge = {
|
|
143
|
+
requestWait: (prompt: AskOperatorPrompt) => Promise<unknown>;
|
|
144
|
+
};
|
|
145
|
+
export type AskOperatorToolOptions = AskOperatorWaitBridge;
|
|
146
|
+
export type AskOperatorToolDetails = {
|
|
147
|
+
prompt: AskOperatorPrompt | null;
|
|
148
|
+
answer: AskOperatorAnswer | null;
|
|
149
|
+
error: string;
|
|
150
|
+
};
|
|
151
|
+
export declare function createAskOperatorTool(options: AskOperatorToolOptions): {
|
|
152
|
+
name: string;
|
|
153
|
+
label: string;
|
|
154
|
+
description: string;
|
|
155
|
+
parameters: Type.TUnion<[Type.TObject<{
|
|
156
|
+
kind: Type.TLiteral<"free_text">;
|
|
157
|
+
message: Type.TString;
|
|
158
|
+
id: Type.TOptional<Type.TString>;
|
|
159
|
+
}>, Type.TObject<{
|
|
160
|
+
kind: Type.TLiteral<"confirm">;
|
|
161
|
+
message: Type.TString;
|
|
162
|
+
id: Type.TOptional<Type.TString>;
|
|
163
|
+
}>, Type.TObject<{
|
|
164
|
+
kind: Type.TLiteral<"multi_question">;
|
|
165
|
+
questions: Type.TArray<Type.TObject<{
|
|
166
|
+
kind: Type.TUnion<[Type.TLiteral<"free_text">, Type.TLiteral<"confirm">]>;
|
|
167
|
+
message: Type.TString;
|
|
168
|
+
id: Type.TOptional<Type.TString>;
|
|
169
|
+
}>>;
|
|
170
|
+
id: Type.TOptional<Type.TString>;
|
|
171
|
+
}>, Type.TObject<{
|
|
172
|
+
kind: Type.TLiteral<"artifact_backed">;
|
|
173
|
+
message: Type.TString;
|
|
174
|
+
artifacts: Type.TArray<Type.TString>;
|
|
175
|
+
id: Type.TOptional<Type.TString>;
|
|
176
|
+
}>]>;
|
|
177
|
+
execute: (_toolCallId: string, params: unknown) => Promise<{
|
|
178
|
+
content: {
|
|
179
|
+
type: "text";
|
|
180
|
+
text: string;
|
|
181
|
+
}[];
|
|
182
|
+
details: AskOperatorToolDetails;
|
|
183
|
+
isError?: true | undefined;
|
|
184
|
+
}>;
|
|
185
|
+
};
|