@corvio/cli 0.1.0-beta.37 → 0.1.0-beta.38
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 +10 -0
- package/dist/cli.js +117 -10
- package/dist/core.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,6 +10,9 @@ corvio auth status
|
|
|
10
10
|
corvio agents connect --provider codex --project . --json
|
|
11
11
|
corvio collaboration status --json --no-input
|
|
12
12
|
corvio ask --prompt 'Summarize recurring launch risks' --json
|
|
13
|
+
corvio ask --background --prompt 'Reconcile the current launch evidence' --json
|
|
14
|
+
corvio questions operation <operation_id> --after-cursor <progress_cursor> --wait-until-terminal --json
|
|
15
|
+
corvio questions cancel <operation_id> --yes --json
|
|
13
16
|
corvio files upload --file ./research.pdf --json
|
|
14
17
|
corvio files get <asset_id> --content --json
|
|
15
18
|
corvio files organize <asset_id> --instruction 'Create a reusable decision brief' --yes --wait-until-terminal --timeout-seconds 1200 --json
|
|
@@ -54,6 +57,13 @@ Read the terminal Question receipt and use `artifact.url` or
|
|
|
54
57
|
`links.primary_artifact` verbatim; `reader_output` artifacts are deliverables, `structure_container` artifacts are hierarchy, and
|
|
55
58
|
`node_id` is never a document URL.
|
|
56
59
|
|
|
60
|
+
For a Question that may outlive one host turn, add `--background`. The command returns one durable `operation_id` immediately. Continue
|
|
61
|
+
that same operation with `corvio questions operation`; `--wait-until-terminal` keeps the status loop inside the CLI, while
|
|
62
|
+
`--after-cursor` returns only later user-visible milestones. A local deadline is not remote cancellation. Use
|
|
63
|
+
`corvio questions cancel <operation_id> --yes` to request a stop, and do not report success until the returned state is actually
|
|
64
|
+
`cancelled`. Progress is a bounded phase summary, never hidden reasoning or a provisional final answer. To correct the objective, finish
|
|
65
|
+
or cancel the current operation and start a successor `corvio ask --conversation-id <conversation_id>` rather than silently replacing it.
|
|
66
|
+
|
|
57
67
|
Treat files as a value ladder, not one upload event. Upload/finalize preserves the exact original, provenance, hash, policy, and stable Asset ID. A selected Markdown file can become an editable Page through `corvio docs create --file`; for other formats or a coherent source set, use `corvio files organize` or `corvio ask --allow-actions` to produce the reader-facing Page, Spreadsheet, Presentation, Code, HTML Artifact, or reading layer that fits the task. Stable facts/preferences may enter Memory; only an evidence-backed reusable method, configuration, constraint, or quality bar should become a Project Skill.
|
|
58
68
|
|
|
59
69
|
Use `corvio files get <asset_id> --content` when the task needs only bounded facts from one retained source. The response preserves the immutable original as authority, reports its source hash and whether the projection is complete or truncated, and does not create a Question or materialize another document. Never infer unseen workbook rows/sheets or document sections.
|
package/dist/cli.js
CHANGED
|
@@ -39,7 +39,7 @@ import {
|
|
|
39
39
|
agentCredentialPath,
|
|
40
40
|
} from "./core.js";
|
|
41
41
|
|
|
42
|
-
const VERSION = "0.1.0-beta.
|
|
42
|
+
const VERSION = "0.1.0-beta.38";
|
|
43
43
|
const DEFAULT_API_BASE = "https://api.corvio.ai/v1";
|
|
44
44
|
const DEFAULT_APP_BASE = "https://corvio.ai";
|
|
45
45
|
const USER_AGENT = `corvio-cli/${VERSION}`;
|
|
@@ -49,6 +49,7 @@ const MAX_MARKDOWN_CHARACTERS = 120_000;
|
|
|
49
49
|
const DEFAULT_FILE_OPERATION_WAIT_TIMEOUT_SECONDS = 1_200;
|
|
50
50
|
const MAX_FILE_OPERATION_WAIT_TIMEOUT_SECONDS = 7_200;
|
|
51
51
|
const FILE_OPERATION_PENDING_STATUSES = new Set(["accepted", "pending", "prepared", "queued", "running"]);
|
|
52
|
+
const QUESTION_OPERATION_PENDING_STATUSES = new Set(["queued", "running"]);
|
|
52
53
|
const READ_ONLY_LOCAL_STATE_ERROR_CODES = new Set(["EACCES", "EPERM", "EROFS"]);
|
|
53
54
|
const CORVIO_SKILL_ARCHIVE = "https://corvio.ai/developers/skills/corvio-operate-workspace/corvio-operate-workspace.zip";
|
|
54
55
|
const AGENT_SKILLS_INSTALLER_VERSION = "1.5.23";
|
|
@@ -88,7 +89,7 @@ const COMMAND_OPTIONS = Object.freeze({
|
|
|
88
89
|
"ask:": [
|
|
89
90
|
"prompt", "conversation-id", "sources", "allow-actions", "context-file", "idempotency-key",
|
|
90
91
|
"processing-profile", "max-processing-profile", "scan-mode", "skills-extraction-mode", "caller-model",
|
|
91
|
-
"file", "asset-ids", "mime-type",
|
|
92
|
+
"file", "asset-ids", "mime-type", "background",
|
|
92
93
|
],
|
|
93
94
|
"agents:list": ["include-revoked"],
|
|
94
95
|
"agents:connect": [
|
|
@@ -114,6 +115,8 @@ const COMMAND_OPTIONS = Object.freeze({
|
|
|
114
115
|
],
|
|
115
116
|
"questions:list": ["limit", "cursor", "conversation-id"],
|
|
116
117
|
"questions:get": ["id"],
|
|
118
|
+
"questions:operation": ["id", "after-cursor", "wait-until-terminal", "timeout-seconds"],
|
|
119
|
+
"questions:cancel": ["id"],
|
|
117
120
|
"conversations:list": ["limit", "cursor"],
|
|
118
121
|
"conversations:get": ["id"],
|
|
119
122
|
"search:": ["query", "limit", "page-id", "node-id"],
|
|
@@ -171,7 +174,7 @@ Usage:
|
|
|
171
174
|
corvio ask --prompt <text> [--file <path>] [--asset-ids <id,id>] [--conversation-id <id>] [--allow-actions] [--processing-profile auto|economy|standard|deep]
|
|
172
175
|
corvio agents list|connect|create|update|rotate [id]
|
|
173
176
|
corvio agent claim|renew|complete|fail|comments|comment|reply|status|closeout|run [id]
|
|
174
|
-
corvio questions list|get [id]
|
|
177
|
+
corvio questions list|get|operation|cancel [id]
|
|
175
178
|
corvio conversations list|get [id]
|
|
176
179
|
corvio search <query>
|
|
177
180
|
corvio docs list|get|read|patch|table-read|table-mutate|create|update|move|archive|restore|share|open [id]
|
|
@@ -197,10 +200,10 @@ const COMMAND_HELP = Object.freeze({
|
|
|
197
200
|
workspaces: `Usage:\n corvio workspaces list\n corvio workspaces use <workspace-id>\n corvio workspaces current\n corvio workspaces create --name <name> [--kind personal|team]\n\nWorkspace status and blocked capability reasons are returned with each item.`,
|
|
198
201
|
capabilities: `Usage: corvio capabilities [--json]\n\nShow live API resources, principal scopes, selected Workspace status, and CLI compatibility.`,
|
|
199
202
|
collaboration: `Usage:\n corvio collaboration status [--project <path>] [--provider codex|claude_code|copilot|workbuddy]\n\nCheck local Corvio prerequisites and every discoverable Corvio Skill copy. Current copies stay quiet; non-current receipts include one compact Agent notice and a source-aware next action. Standalone refresh commands pin the verified installer, select exactly one provider, and preserve project/global scope. WorkBuddy inspection is read-only and never changes ~/.workbuddy. The CLI cannot prove that the current host task loaded a particular copy, or whether remote MCP or host memory is active.`,
|
|
200
|
-
ask: `Usage: corvio ask --prompt <text> [--file <path>] [--asset-ids <id,id>] [--conversation-id <id>] [--sources workspace,web,memory] [--allow-actions] [--processing-profile auto|economy|standard|deep] [--max-processing-profile economy|standard|deep] [--scan-mode auto|always|off] [--skills-extraction-mode auto|always|off] [--caller-model <host-model>] [--context-file <json>] [--idempotency-key <key>]\n\nAnswer-only is the default: omit --allow-actions; there is no --mode option. Keep the user's natural question unchanged, then append the smallest complete decision-relevant context or stable handles as a separate clause. A carried Project handle normally bounds a cross-branch question without enumerating all descendants. Handles are evidence addresses: do not invent a comparison rubric, prescribe reasoning steps, substitute another user objective, or turn current Tree labels into a detailed task plan. Unless the user chose them, do not invent taxonomy, titles, artifact count, or Corvio's internal plan; Corvio chooses the cognitive structure and carriers. In a bounded read-only continuation, start this foreground command exactly once when a trusted current-task or prior receipt already proves this authenticated CLI and exact Workspace; do not launch an identical Question concurrently or retry before terminal exit. If the
|
|
203
|
+
ask: `Usage: corvio ask --prompt <text> [--file <path>] [--asset-ids <id,id>] [--conversation-id <id>] [--sources workspace,web,memory] [--allow-actions] [--background] [--processing-profile auto|economy|standard|deep] [--max-processing-profile economy|standard|deep] [--scan-mode auto|always|off] [--skills-extraction-mode auto|always|off] [--caller-model <host-model>] [--context-file <json>] [--idempotency-key <key>]\n\nAnswer-only is the default: omit --allow-actions; there is no --mode option. Keep the user's natural question unchanged, then append the smallest complete decision-relevant context or stable handles as a separate clause. A carried Project handle normally bounds a cross-branch question without enumerating all descendants. Handles are evidence addresses: do not invent a comparison rubric, prescribe reasoning steps, substitute another user objective, or turn current Tree labels into a detailed task plan. Unless the user chose them, do not invent taxonomy, titles, artifact count, or Corvio's internal plan; Corvio chooses the cognitive structure and carriers. In a bounded read-only continuation, start this foreground command exactly once when a trusted current-task or prior receipt already proves this authenticated CLI and exact Workspace; do not launch an identical Question concurrently or retry before terminal exit. If the shell tool yields a running-session handle, wait on that exact handle until the CLI exits instead of answering from prior context. It returns the terminal Question without model-visible polling. Use --background for work that should outlive the current shell; it returns one durable operation immediately. Inspect it with questions operation, stop it with questions cancel, and use the terminal conversation_id for a corrected follow-up instead of silently changing an in-flight objective. Transport continuity does not prove a cheaper processing profile; leave processing on auto unless the remaining transformation independently justifies another profile. Do not install, probe, or switch to the CLI only to avoid MCP polling, and do not extend it to an unbound Workspace. --file retains the selected local file, verifies its hash, and attaches the finalized Asset to this exact question. --asset-ids attaches already-retained Corvio Assets. Use --allow-actions when Corvio should create the Page, Spreadsheet, Presentation, Code, HTML Artifact, Memory, or qualifying Project Skill that best serves the result. A continuation handle is subject evidence, not necessarily the durable write destination: for a reusable pattern or method, resolve the fitting same-scope Memory or Skill owner before admitting or merging it. Read the terminal Question receipt and use artifact.url or links.primary_artifact verbatim; reader_output artifacts are deliverables, structure_container artifacts are hierarchy, and node_id is never a document URL. Upload alone is not evidence of interpretation. Skill extraction mode always requires --allow-actions and an evidence-backed decision, not forced Skill creation; answer-only questions may use auto or off.`,
|
|
201
204
|
agents: `Usage:\n corvio agents list\n corvio agents connect [--provider codex|claude_code|copilot] [--project <path>] [--permission-profile read_only|workspace_write|danger_full_access] [--trigger-policy owner_only|workspace_members] [--display-name <name>] [--recover-credential] [--no-listen]\n corvio agents create --handle <handle> --display-name <name> [--provider codex|claude_code|copilot|custom] [--permissions read,comment,edit]\n corvio agents update <id> [--display-name <name>] [--status active|paused|revoked] [--permissions <list>]\n corvio agents rotate <id>\n\n'connect' binds the current Git project (or --project path) to one stable personal Agent. Repeating it is idempotent; another project creates another Agent. It reports provider/CLI, listener, and local Skill prerequisites separately; run corvio collaboration status after installing or refreshing the Skill. The CLI cannot prove that the current host task loaded those surfaces. The default workspace_write profile is limited by the provider's native sandbox. owner_only is the safe trigger default. Secrets and absolute project paths stay local.`,
|
|
202
205
|
agent: `Usage:\n corvio agent claim [--worker-id <id>] [--wait-seconds <0-30>]\n corvio agent renew <event-id> --lease-token <token> [--lease-seconds <30-900>]\n corvio agent complete <event-id> --lease-token <token> [--result-file <json>]\n corvio agent fail <event-id> --lease-token <token> --error <message>\n corvio agent mentions --document-id <id> [--query <name>]\n corvio agent comments --document-id <id>\n corvio agent comment --document-id <id> --body <text> [--selection-file <json>] [--start-new-chain] [--idempotency-key <key>]\n corvio agent reply <thread-id> --document-id <id> --body <text> [--source-event-id <id> --source-event-lease-token <token>|--start-new-chain] [--idempotency-key <key>]\n corvio agent status <thread-id> --document-id <id> --status open|resolved\n corvio agent closeout --document-id <id> [--thread-id <id>] --body <verified-result> [--status open|resolved] [--idempotency-key <key>]\n corvio agent run [--provider codex|claude_code|copilot|custom] [--handler <executable>] [--agent <id>] [--once] [--processing-profile auto|economy|standard|deep] [--max-processing-profile economy|standard|deep] [--scan-mode auto|always|off] [--skills-extraction-mode auto|always|off] [--caller-model <host-model>]\n\nUse mentions before commenting when the target is uncertain; aliases resolve to stable user or Agent IDs and ambiguity fails closed. Use closeout when a Corvio document or comment owned the task: it returns the verified result to that surface and reads document/comments back. Agent-to-Agent comments require either a claimed source event or explicit --start-new-chain. The runner iteratively exchanges origin-scoped evidence with Corvio Query/Writer, then invokes the bound provider inside its local project. Local code changes use the recorded provider permission profile; complex Corvio document changes belong to Query/Writer. Provider children never receive Corvio credentials.`,
|
|
203
|
-
questions: `Usage:\n corvio questions list [--limit <n>] [--cursor <cursor>] [--conversation-id <id>]\n corvio questions get <question-id
|
|
206
|
+
questions: `Usage:\n corvio questions list [--limit <n>] [--cursor <cursor>] [--conversation-id <id>]\n corvio questions get <question-id>\n corvio questions operation <operation-id> [--after-cursor <n>] [--wait-until-terminal] [--timeout-seconds <1-7200>]\n corvio questions cancel <operation-id> --yes\n\nA Question operation is the durable owner for background work. operation returns only new user-visible milestones after --after-cursor and never exposes hidden reasoning or provisional answer text. --wait-until-terminal keeps deterministic polling in this process and returns a typed deadline receipt if the local deadline expires. cancel is idempotent; treat cancellation_requested as non-terminal and verify cancelled before telling the user the task stopped. Cancellation does not roll back effects that already settled. To correct the objective, stop or finish the current operation, then use corvio ask --conversation-id <conversation_id> so the new Question is an explicit successor.`,
|
|
204
207
|
conversations: `Usage:\n corvio conversations list [--limit <n>] [--cursor <cursor>]\n corvio conversations get <conversation-id>`,
|
|
205
208
|
search: `Usage: corvio search <query> [--limit <n>] [--page-id <id>] [--node-id <id>]`,
|
|
206
209
|
docs: `Usage:\n corvio docs list [--limit <n>] [--cursor <cursor>] [--lifecycle active|archived]\n corvio docs get <id> [--output <path>]\n corvio docs read <id> [--mode auto|overview|line-range|section|search|full] [--start-line <n> --end-line <n>|--section-ref <S#>|--query <text>] [--max-chars <n>]\n corvio docs patch <id> --input <json> --yes [--operation-id <id>] [--change-summary <text>]\n corvio docs table-read <id> [--table-id <id>] [--after-row-id <id>] [--limit <1-100>]\n corvio docs table-mutate <id> --input <json> --yes [--operation-id <id>] [--change-summary <text>]\n corvio docs create --title <title> [--file <path>|--markdown <text>] [--parent-node-id <id>] [--idempotency-key <key>]\n corvio docs update <id> [--title <title>] [--file <path>|--markdown <text>] [--expected-revision <n>] [--change-summary <text>]\n corvio docs move <id> --parent-node-id <id>\n corvio docs archive <id> --yes\n corvio docs restore <id> --yes\n corvio docs share <id> --yes [--display-name <name>]\n corvio docs open <id>\n\nUse \`docs read --mode auto\` first for a small full body or a large-document overview, then read an exact section or line range. Use \`docs patch\` when the host already knows 1-20 exact L# replacements; it preserves untouched lines and returns a compact verified delta. A selected Markdown file can become an editable Page without resending the body through the model. Use \`docs update\` only when whole-body replacement is the smallest faithful change. Delegate document-wide judgment, cross-source synthesis, structure/formatting interpretation, and typed Spreadsheet, Presentation, Code, or HTML work to \`corvio ask --allow-actions\`. A Project is a structure container; body writes fail with project_structure_container_body_write_disabled, while a title-only Project rename remains valid. Projects stay at the Workspace root and cannot be nested; use \`files organize\` or \`ask --allow-actions\` for Work Model maintenance. Use table-read plus table-mutate for bounded stable-ID cell updates or row appends. Agent-authenticated document changes require --change-summary and create a visible document-level comment after the guarded update. When a document/comment is the task owner, use \`corvio agent closeout\` to return verified work to that same collaboration surface and read it back.`,
|
|
@@ -258,6 +261,8 @@ function validateInvocation(options, positionals) {
|
|
|
258
261
|
const actionsWithId = new Set([
|
|
259
262
|
"workspaces:use",
|
|
260
263
|
"questions:get",
|
|
264
|
+
"questions:operation",
|
|
265
|
+
"questions:cancel",
|
|
261
266
|
"conversations:get",
|
|
262
267
|
"docs:get",
|
|
263
268
|
"docs:read",
|
|
@@ -1274,7 +1279,7 @@ async function ask(options, positionals) {
|
|
|
1274
1279
|
const uniqueAssetIds = [...new Set(assetIds.map((value) => String(value).trim()).filter(Boolean))];
|
|
1275
1280
|
let result;
|
|
1276
1281
|
try {
|
|
1277
|
-
result = await api.request("/questions", {
|
|
1282
|
+
result = await api.request(options.background ? "/question-operations" : "/questions", {
|
|
1278
1283
|
method: "POST",
|
|
1279
1284
|
headers: {
|
|
1280
1285
|
"idempotency-key": idempotencyKey(options),
|
|
@@ -1292,7 +1297,7 @@ async function ask(options, positionals) {
|
|
|
1292
1297
|
skills_extraction_mode: skillsExtractionMode,
|
|
1293
1298
|
context,
|
|
1294
1299
|
},
|
|
1295
|
-
timeoutMs: 330_000,
|
|
1300
|
+
timeoutMs: options.background ? 30_000 : 330_000,
|
|
1296
1301
|
});
|
|
1297
1302
|
} catch (error) {
|
|
1298
1303
|
if (attachedAssets.length > 0) {
|
|
@@ -2952,12 +2957,114 @@ function pageQuery(options) {
|
|
|
2952
2957
|
|
|
2953
2958
|
async function questions(options, action, id) {
|
|
2954
2959
|
const { api } = await executionClient(options, { continuityId: options["conversation-id"] || null });
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2960
|
+
let result;
|
|
2961
|
+
if (action === "list") {
|
|
2962
|
+
result = await api.request("/questions", { query: pageQuery(options) });
|
|
2963
|
+
} else if (action === "get") {
|
|
2964
|
+
result = await api.request(`/questions/${resourcePath(id || option(options, "id", { required: true }))}`);
|
|
2965
|
+
} else if (action === "operation") {
|
|
2966
|
+
const operationId = id || option(options, "id", { required: true });
|
|
2967
|
+
const afterCursor = numberOption(options, "after-cursor", 0, { minimum: 0 });
|
|
2968
|
+
const timeoutSeconds = questionOperationWaitTimeoutSeconds(options);
|
|
2969
|
+
result = timeoutSeconds === null
|
|
2970
|
+
? await api.request(`/question-operations/${resourcePath(operationId)}`, {
|
|
2971
|
+
query: { after_cursor: afterCursor },
|
|
2972
|
+
})
|
|
2973
|
+
: await waitForQuestionOperation(api, operationId, {
|
|
2974
|
+
afterCursor,
|
|
2975
|
+
timeoutSeconds,
|
|
2976
|
+
});
|
|
2977
|
+
} else if (action === "cancel") {
|
|
2978
|
+
const operationId = id || option(options, "id", { required: true });
|
|
2979
|
+
requireConfirmation(options, `Cancelling Question operation ${operationId}`);
|
|
2980
|
+
result = await api.request(`/question-operations/${resourcePath(operationId)}/cancel`, {
|
|
2981
|
+
method: "POST",
|
|
2982
|
+
retrySafe: true,
|
|
2983
|
+
});
|
|
2984
|
+
} else {
|
|
2985
|
+
throw new CliError("questions action must be list, get, operation, or cancel.");
|
|
2986
|
+
}
|
|
2958
2987
|
writeResult(result, { json: options.json });
|
|
2959
2988
|
}
|
|
2960
2989
|
|
|
2990
|
+
function questionOperationWaitTimeoutSeconds(options) {
|
|
2991
|
+
if (!options["wait-until-terminal"]) {
|
|
2992
|
+
if (options["timeout-seconds"] !== undefined) {
|
|
2993
|
+
throw new CliError("--timeout-seconds requires --wait-until-terminal.", {
|
|
2994
|
+
code: "question_operation_wait_required",
|
|
2995
|
+
});
|
|
2996
|
+
}
|
|
2997
|
+
return null;
|
|
2998
|
+
}
|
|
2999
|
+
return numberOption(
|
|
3000
|
+
options,
|
|
3001
|
+
"timeout-seconds",
|
|
3002
|
+
DEFAULT_FILE_OPERATION_WAIT_TIMEOUT_SECONDS,
|
|
3003
|
+
{ minimum: 1, maximum: MAX_FILE_OPERATION_WAIT_TIMEOUT_SECONDS },
|
|
3004
|
+
);
|
|
3005
|
+
}
|
|
3006
|
+
|
|
3007
|
+
function questionOperationIsPending(result) {
|
|
3008
|
+
return QUESTION_OPERATION_PENDING_STATUSES.has(String(result?.status || "").trim().toLowerCase());
|
|
3009
|
+
}
|
|
3010
|
+
|
|
3011
|
+
function questionOperationDeadlineReceipt(result, { timeoutSeconds, startedAtMs, operationReadCount }) {
|
|
3012
|
+
return {
|
|
3013
|
+
...result,
|
|
3014
|
+
transport_wait: {
|
|
3015
|
+
status: "deadline_reached",
|
|
3016
|
+
terminal: false,
|
|
3017
|
+
timeout_seconds: timeoutSeconds,
|
|
3018
|
+
elapsed_seconds: Math.max(0, Math.round((Date.now() - startedAtMs) / 1000)),
|
|
3019
|
+
operation_read_count: operationReadCount,
|
|
3020
|
+
continuation: "Run the same questions operation command with --wait-until-terminal; do not start a replacement Question.",
|
|
3021
|
+
},
|
|
3022
|
+
};
|
|
3023
|
+
}
|
|
3024
|
+
|
|
3025
|
+
async function waitForQuestionOperation(api, operationId, { afterCursor, timeoutSeconds }) {
|
|
3026
|
+
const startedAtMs = Date.now();
|
|
3027
|
+
const deadlineAtMs = startedAtMs + timeoutSeconds * 1000;
|
|
3028
|
+
let cursor = Math.max(0, Number(afterCursor) || 0);
|
|
3029
|
+
let result = null;
|
|
3030
|
+
let operationReadCount = 0;
|
|
3031
|
+
while (true) {
|
|
3032
|
+
const remainingMs = deadlineAtMs - Date.now();
|
|
3033
|
+
if (remainingMs <= 0 && result) {
|
|
3034
|
+
return questionOperationDeadlineReceipt(result, {
|
|
3035
|
+
timeoutSeconds,
|
|
3036
|
+
startedAtMs,
|
|
3037
|
+
operationReadCount,
|
|
3038
|
+
});
|
|
3039
|
+
}
|
|
3040
|
+
result = await api.request(`/question-operations/${resourcePath(operationId)}`, {
|
|
3041
|
+
query: {
|
|
3042
|
+
after_cursor: cursor,
|
|
3043
|
+
wait_seconds: Math.max(0, Math.min(30, Math.ceil(remainingMs / 1000))),
|
|
3044
|
+
},
|
|
3045
|
+
timeoutMs: Math.max(35_000, Math.min(remainingMs + 5_000, 40_000)),
|
|
3046
|
+
});
|
|
3047
|
+
operationReadCount += 1;
|
|
3048
|
+
if (Number.isFinite(Number(result.progress_cursor))) {
|
|
3049
|
+
cursor = Math.max(cursor, Number(result.progress_cursor));
|
|
3050
|
+
}
|
|
3051
|
+
if (!questionOperationIsPending(result)) return result;
|
|
3052
|
+
const nextRemainingMs = deadlineAtMs - Date.now();
|
|
3053
|
+
if (nextRemainingMs <= 0) {
|
|
3054
|
+
return questionOperationDeadlineReceipt(result, {
|
|
3055
|
+
timeoutSeconds,
|
|
3056
|
+
startedAtMs,
|
|
3057
|
+
operationReadCount,
|
|
3058
|
+
});
|
|
3059
|
+
}
|
|
3060
|
+
const retryAfterSeconds = Number(result.retry_after_seconds);
|
|
3061
|
+
const requestedDelayMs = Number.isFinite(retryAfterSeconds) && retryAfterSeconds >= 0
|
|
3062
|
+
? retryAfterSeconds * 1000
|
|
3063
|
+
: 5_000;
|
|
3064
|
+
await sleep(Math.min(nextRemainingMs, Math.max(50, Math.min(30_000, requestedDelayMs))));
|
|
3065
|
+
}
|
|
3066
|
+
}
|
|
3067
|
+
|
|
2961
3068
|
async function conversations(options, action, id) {
|
|
2962
3069
|
const conversationId = action === "get" ? id || options.id || null : null;
|
|
2963
3070
|
const { api } = await executionClient(options, { continuityId: conversationId });
|
package/dist/core.js
CHANGED