@trydreamstate/cli 1.3.3 → 1.3.4
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 +14 -7
- package/agent-plugin/.claude-plugin/plugin.json +1 -1
- package/agent-plugin/.codex-plugin/plugin.json +1 -1
- package/agent-plugin/hooks/approve-readonly.sh +2 -2
- package/agent-plugin/hooks/hooks.json +1 -1
- package/agent-plugin/skills/crm/SKILL.md +2 -2
- package/agent-plugin/skills/diagnostics/SKILL.md +3 -1
- package/agent-plugin/skills/dreamstate/SKILL.md +5 -3
- package/agent-plugin/skills/first-win/SKILL.md +2 -2
- package/agent-plugin/skills/inbox-replies/SKILL.md +3 -1
- package/agent-plugin/skills/knowledge/SKILL.md +3 -5
- package/agent-plugin/skills/linkedin-posts/SKILL.md +3 -1
- package/agent-plugin/skills/linkedin-warm-signals/SKILL.md +2 -2
- package/agent-plugin/skills/list-building/SKILL.md +3 -8
- package/agent-plugin/skills/list-building/column-authoring.md +1 -1
- package/agent-plugin/skills/list-building/sourcing.md +2 -2
- package/agent-plugin/skills/outreach/SKILL.md +2 -2
- package/agent-plugin/skills/plays/SKILL.md +3 -3
- package/agent-plugin/skills/reddit-posts/SKILL.md +3 -1
- package/agent-plugin/skills/skill-authoring/SKILL.md +3 -1
- package/agent-plugin/skills/social/SKILL.md +3 -5
- package/agent-plugin/skills/visibility/SKILL.md +2 -6
- package/agent-plugin/skills/workflows/SKILL.md +2 -2
- package/agent-plugin/skills/workflows/lifecycle-and-enrollment.md +1 -1
- package/agent-plugin/skills/worksheet-tidy/SKILL.md +3 -1
- package/agent-plugin/skills/writing/SKILL.md +3 -5
- package/agent-plugin/skills/x-posts/SKILL.md +3 -1
- package/dist/agentGuidance.generated.json +4 -4
- package/dist/capabilityPosture.d.ts +12 -0
- package/dist/capabilityPosture.d.ts.map +1 -0
- package/dist/capabilityPosture.js +39 -0
- package/dist/client.d.ts +5 -3
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +69 -60
- package/dist/commands/sequences.d.ts +3 -2
- package/dist/commands/sequences.d.ts.map +1 -1
- package/dist/commands/sequences.js +19 -37
- package/dist/commands/shared.d.ts.map +1 -1
- package/dist/commands/shared.js +20 -44
- package/dist/commands/workflows.d.ts +3 -2
- package/dist/commands/workflows.d.ts.map +1 -1
- package/dist/commands/workflows.js +19 -35
- package/dist/errors.d.ts +2 -6
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +10 -43
- package/dist/gatedRun.d.ts +0 -2
- package/dist/gatedRun.d.ts.map +1 -1
- package/dist/gatedRun.js +27 -51
- package/dist/generated/packVerbs.generated.json +492 -0
- package/dist/generated/runContract.generated.d.ts +4 -0
- package/dist/generated/runContract.generated.d.ts.map +1 -0
- package/dist/generated/runContract.generated.js +7 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +49 -28
- package/dist/registryManifest.d.ts +6 -0
- package/dist/registryManifest.d.ts.map +1 -0
- package/dist/registryManifest.js +66 -0
- package/dist/runContract.d.ts +10 -0
- package/dist/runContract.d.ts.map +1 -0
- package/dist/runContract.js +13 -0
- package/dist/runWait.d.ts +0 -1
- package/dist/runWait.d.ts.map +1 -1
- package/dist/runWait.js +0 -13
- package/package.json +4 -2
|
@@ -3,7 +3,7 @@ name: writing
|
|
|
3
3
|
description: "Draft, revise and publish articles and landing copy grounded in workspace context and a target query."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
Run this through the Dreamstate MCP tools: `packs_get` for the pack's capabilities, `tools_get` for the exact input schema, then `tools_run`. Anything that writes, spends credits or reaches a person: dry_run first, then live with the quote_hash the dry_run returned, a max_credits ceiling and an idempotency_key. A larger paid run also needs the user's yes before you send approved: true; never send it on your own. If the server asks you to sign in, approve it in the browser.
|
|
6
|
+
Run this through the Dreamstate MCP tools: `packs_get` for the pack's capabilities, `tools_get` for the exact input schema, then `tools_run`. Anything that writes, spends credits or reaches a person: dry_run first, then live with the quote_hash the dry_run returned, a max_credits ceiling and an idempotency_key. max_credits 0 is valid only when that quote is 0. A larger paid run, or a live external send above the server's recipient threshold, also needs the user's yes before you send approved: true; never send it on your own. `max_rows` is a param of `tables.columns.run` and `tables.table_sources.run`, not of `tools_run`. `max_live_sends` is a param of the external-send sequence capabilities (`sequence.sequences.activate_audience`, `sequence.sequences.resume`, and the rest of that family), sent inside `params`, not a gating input of `tools_run`. The paid-run consent rule is one sentence in the MCP server instructions, rendered from consentRule.json and PAID_RUN_APPROVAL_THRESHOLDS: rows, dollars, credits, and the conversion. If the server asks you to sign in, approve it in the browser.
|
|
7
7
|
|
|
8
8
|
# Writing
|
|
9
9
|
|
|
@@ -14,10 +14,6 @@ Run this through the Dreamstate MCP tools: `packs_get` for the pack's capabiliti
|
|
|
14
14
|
- Short-form social posts: [`social`].
|
|
15
15
|
- The `social` pack lists the tools and their exact inputs.
|
|
16
16
|
|
|
17
|
-
<!-- architect-operation-contract
|
|
18
|
-
{"required_capability_ids":[]}
|
|
19
|
-
-->
|
|
20
|
-
|
|
21
17
|
Own the draft, review, revise, and publish lifecycle for long-form articles and landing copy. Every factual claim traces to a workspace-wiki fact, cited evidence, or a dated external source; the voice matches what the workspace has already published; and each lifecycle step is a deliberate, verifiable state change. Traditional keyword, ranking, and generative-citation evidence belongs to `visibility`; current external evidence and durable facts about the business belong to `knowledge`. Never re-derive those measurements or restate a business fact from memory.
|
|
22
18
|
|
|
23
19
|
Authoring: prepare brief, evidence ledger, novelty decision, destination, and voice; compose internally; discover owner and hydrate schema; save complete artifact; read result before showing or advancing. Unsaved long-form copy in chat is not an article. Preserve exact user-named title. A rewrite is not persisted until live result says save succeeded.
|
|
@@ -82,3 +78,5 @@ Report the missing source, stale revision, failed destination, or missing publis
|
|
|
82
78
|
## Check it works
|
|
83
79
|
|
|
84
80
|
Done means checked, not built. Before you report, read back everything you made or changed, and run, test or preview it where that is offered; publish or send only when the user asked. An empty, failed or wrong result means an input or setting is wrong: find which from the error or the output, correct it and check again, until it is right or a real blocker stops it. Report what you checked and what it showed.
|
|
81
|
+
|
|
82
|
+
Paid and outward runs follow the paid-run consent rule.
|
|
@@ -3,7 +3,7 @@ name: x-posts
|
|
|
3
3
|
description: "Write and revise X posts and threads: the first line, single post versus thread, weighted length and Premium limits, thread structure, post types, replies and links, and phrases to avoid. Use it for the copy of any post going to X. It does not cover scheduling, publishing or automations (social does)."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
Run this through the Dreamstate MCP tools: `packs_get` for the pack's capabilities, `tools_get` for the exact input schema, then `tools_run`. Anything that writes, spends credits or reaches a person: dry_run first, then live with the quote_hash the dry_run returned, a max_credits ceiling and an idempotency_key. A larger paid run also needs the user's yes before you send approved: true; never send it on your own. If the server asks you to sign in, approve it in the browser.
|
|
6
|
+
Run this through the Dreamstate MCP tools: `packs_get` for the pack's capabilities, `tools_get` for the exact input schema, then `tools_run`. Anything that writes, spends credits or reaches a person: dry_run first, then live with the quote_hash the dry_run returned, a max_credits ceiling and an idempotency_key. max_credits 0 is valid only when that quote is 0. A larger paid run, or a live external send above the server's recipient threshold, also needs the user's yes before you send approved: true; never send it on your own. `max_rows` is a param of `tables.columns.run` and `tables.table_sources.run`, not of `tools_run`. `max_live_sends` is a param of the external-send sequence capabilities (`sequence.sequences.activate_audience`, `sequence.sequences.resume`, and the rest of that family), sent inside `params`, not a gating input of `tools_run`. The paid-run consent rule is one sentence in the MCP server instructions, rendered from consentRule.json and PAID_RUN_APPROVAL_THRESHOLDS: rows, dollars, credits, and the conversion. If the server asks you to sign in, approve it in the browser.
|
|
7
7
|
|
|
8
8
|
# X posts
|
|
9
9
|
|
|
@@ -71,3 +71,5 @@ Change what was asked and keep the rest verbatim. If a thread post runs long, sp
|
|
|
71
71
|
## Check it works
|
|
72
72
|
|
|
73
73
|
Read the saved draft back: the hook alone justifies post two, each post is under the account's limit, each thread post stands alone, every number traces to something real, and nothing contains an em dash.
|
|
74
|
+
|
|
75
|
+
Paid and outward runs follow the paid-run consent rule.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"generated_by": "packages/cli/scripts/build-agent-plugin.mjs from apps/backend/src/services/mcp/consentRule.json; do not edit by hand",
|
|
3
3
|
"consent": {
|
|
4
|
-
"summary": "Anything that writes, spends credits or reaches a person: dry_run first, then live with the quote_hash the dry_run returned, a max_credits ceiling and an idempotency_key. A larger paid run also needs the user's yes before you send approved: true; never send it on your own.",
|
|
5
|
-
"paid_run": "Anything that writes, spends credits or reaches a real person: run mode dry_run first, show the user the preview, the row count and the credit estimate, then run live with the quote_hash that dry_run returned, a max_credits ceiling and an idempotency_key.
|
|
6
|
-
"human_approval": "A paid run above the server's row or provider-spend limit, or that turns on a recurring trigger, also needs the user's yes. Ask them, and only then send approved: true with the same quote_hash. You are asserting that you asked a person; never send it on your own."
|
|
4
|
+
"summary": "Anything that writes, spends credits or reaches a person: dry_run first, then live with the quote_hash the dry_run returned, a max_credits ceiling and an idempotency_key. max_credits 0 is valid only when that quote is 0. A larger paid run, or a live external send above the server's recipient threshold, also needs the user's yes before you send approved: true; never send it on your own.",
|
|
5
|
+
"paid_run": "Anything that writes, spends credits or reaches a real person: run mode dry_run first, show the user the preview, the row count and the credit estimate, then run live with the quote_hash that dry_run returned, a max_credits ceiling and an idempotency_key. max_credits 0 is valid only when that quote is 0. A live paid run states max_rows; an external send states max_live_sends of at least the dry_run recipient_count. A quote returned by a refused live call is only a price, never a confirmation.",
|
|
6
|
+
"human_approval": "A paid run above the server's row or provider-spend limit, a live external send above the server's recipient threshold, or a run that turns on a recurring trigger, also needs the user's yes. Ask them, and only then send approved: true with the same quote_hash. You are asserting that you asked a person; never send it on your own."
|
|
7
7
|
},
|
|
8
8
|
"router_steps": [
|
|
9
9
|
{
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
{
|
|
25
25
|
"mcp": "tools_run",
|
|
26
26
|
"cli": "dreamstate tools run <capability_id> --params '{...}' --mode <dry_run|live> --json",
|
|
27
|
-
"text": "runs it with `capability_id` and `params`. The gating inputs (`mode`, `max_credits`, `idempotency_key`, `quote_hash`, `
|
|
27
|
+
"text": "runs it with `capability_id` and `params`. The gating inputs (`mode`, `max_credits`, `idempotency_key`, `quote_hash`, `approved`) go on the run call itself, never inside `params`. `max_rows` is a param of `tables.columns.run` and `tables.table_sources.run`, not of `tools_run`. `max_live_sends` is a param of the external-send sequence capabilities (`sequence.sequences.activate_audience`, `sequence.sequences.resume`, and the rest of that family), sent inside `params`, not a gating input of `tools_run`."
|
|
28
28
|
},
|
|
29
29
|
{
|
|
30
30
|
"mcp": "runs_get",
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inline-read and column-run hand-off, derived from the tools-get capability
|
|
3
|
+
* record. No capability id list: a free synchronous read omits the turn token,
|
|
4
|
+
* and a queued external test run (column runs and the same posture class)
|
|
5
|
+
* returns without waiting.
|
|
6
|
+
*/
|
|
7
|
+
export interface CapabilityPosture {
|
|
8
|
+
inlineRead: boolean;
|
|
9
|
+
returnsRunId: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function postureFromContract(fetched: unknown): CapabilityPosture;
|
|
12
|
+
//# sourceMappingURL=capabilityPosture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capabilityPosture.d.ts","sourceRoot":"","sources":["../src/capabilityPosture.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,OAAO,CAAC;IACpB,YAAY,EAAE,OAAO,CAAC;CACvB;AAaD,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,iBAAiB,CAkBvE"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Inline-read and column-run hand-off, derived from the tools-get capability
|
|
4
|
+
* record. No capability id list: a free synchronous read omits the turn token,
|
|
5
|
+
* and a queued external test run (column runs and the same posture class)
|
|
6
|
+
* returns without waiting.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.postureFromContract = postureFromContract;
|
|
10
|
+
function record(value) {
|
|
11
|
+
return value && typeof value === 'object' && !Array.isArray(value) ? value : null;
|
|
12
|
+
}
|
|
13
|
+
function capabilityOf(fetched) {
|
|
14
|
+
const root = record(fetched);
|
|
15
|
+
if (!root)
|
|
16
|
+
return null;
|
|
17
|
+
const data = record(root.data);
|
|
18
|
+
return record(data?.capability) ?? record(root.capability);
|
|
19
|
+
}
|
|
20
|
+
function postureFromContract(fetched) {
|
|
21
|
+
const capability = capabilityOf(fetched);
|
|
22
|
+
if (!capability)
|
|
23
|
+
return { inlineRead: false, returnsRunId: false };
|
|
24
|
+
const asyncPolicy = record(capability.async_policy);
|
|
25
|
+
const asyncMode = typeof asyncPolicy?.mode === 'string' ? asyncPolicy.mode : undefined;
|
|
26
|
+
const credit = typeof capability.credit_class === 'string' ? capability.credit_class : undefined;
|
|
27
|
+
const consequence = typeof capability.consequence === 'string' ? capability.consequence : undefined;
|
|
28
|
+
const effect = typeof capability.effect_class === 'string' ? capability.effect_class : undefined;
|
|
29
|
+
// Missing async_policy is unknown. Do not guess sync, and do not treat it as a hand-off.
|
|
30
|
+
const inlineRead = capability.mutates !== true
|
|
31
|
+
&& asyncMode === 'sync'
|
|
32
|
+
&& (credit === 'free' || credit === undefined)
|
|
33
|
+
&& (consequence === 'read_only' || consequence === 'test_run');
|
|
34
|
+
const returnsRunId = asyncMode === 'async'
|
|
35
|
+
&& consequence === 'test_run'
|
|
36
|
+
&& credit === 'dynamic'
|
|
37
|
+
&& effect === 'external';
|
|
38
|
+
return { inlineRead, returnsRunId };
|
|
39
|
+
}
|
package/dist/client.d.ts
CHANGED
|
@@ -3,9 +3,10 @@ export declare const CLI_VERSION: string;
|
|
|
3
3
|
export declare const CLI_UPDATE_COMMAND = "npm install -g @trydreamstate/cli@latest";
|
|
4
4
|
/**
|
|
5
5
|
* Release identity the server stamps on every /api/v1 response (contract C2):
|
|
6
|
-
* meta.server_version, meta.minimum_cli_version
|
|
7
|
-
* JSON envelope
|
|
8
|
-
* -
|
|
6
|
+
* meta.server_version, meta.minimum_cli_version, meta.release_sha and
|
|
7
|
+
* meta.registry_hash in the JSON envelope (whoami also puts registry_hash on
|
|
8
|
+
* data), and X-Dreamstate-Server-Version / -Minimum-Cli-Version / -Release-Sha
|
|
9
|
+
* / -Registry-Hash as response headers. The client reads both so a server that
|
|
9
10
|
* only sets one of them (a proxy that rewrites bodies, an error page with no
|
|
10
11
|
* envelope) still reports skew.
|
|
11
12
|
*/
|
|
@@ -13,6 +14,7 @@ export interface ServerReleaseInfo {
|
|
|
13
14
|
server_version: string | null;
|
|
14
15
|
minimum_cli_version: string | null;
|
|
15
16
|
release_sha: string | null;
|
|
17
|
+
registry_hash: string | null;
|
|
16
18
|
}
|
|
17
19
|
export interface DreamstateClientOptions {
|
|
18
20
|
apiKey: string;
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,WAAW,EAAE,MAA2C,CAAC;AAEtE,uFAAuF;AACvF,eAAO,MAAM,kBAAkB,6CAA6C,CAAC;AAE7E;;;;;;;;GAQG;AACH,MAAM,WAAW,iBAAiB;IAChC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,mBAAmB,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,+FAA+F;I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GAAG,IAAI,GAC7B,OAAO,CAAC,OAAO,CAAC;IAYnB,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAGpC,QAAQ,CAAC,KAAK,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAG/D,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAG/E,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAW/F,OAAO,CAAC,cAAc;YAUR,OAAO;CAuGtB"}
|
package/dist/client.js
CHANGED
|
@@ -8,6 +8,7 @@ exports.requestDeviceAuthorization = requestDeviceAuthorization;
|
|
|
8
8
|
exports.claimDeviceAuthorization = claimDeviceAuthorization;
|
|
9
9
|
const idempotency_1 = require("./idempotency");
|
|
10
10
|
const errors_1 = require("./errors");
|
|
11
|
+
const registryManifest_1 = require("./registryManifest");
|
|
11
12
|
exports.CLI_VERSION = require('../package.json').version;
|
|
12
13
|
/** Command that updates the CLI. One constant so every surface prints the same one. */
|
|
13
14
|
exports.CLI_UPDATE_COMMAND = 'npm install -g @trydreamstate/cli@latest';
|
|
@@ -60,9 +61,11 @@ class CliError extends Error {
|
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
63
|
exports.CliError = CliError;
|
|
64
|
+
function objectRecord(value) {
|
|
65
|
+
return value && typeof value === 'object' && !Array.isArray(value) ? value : undefined;
|
|
66
|
+
}
|
|
63
67
|
function metaRecord(payload) {
|
|
64
|
-
|
|
65
|
-
return meta && typeof meta === 'object' && !Array.isArray(meta) ? meta : undefined;
|
|
68
|
+
return objectRecord(objectRecord(payload)?.meta);
|
|
66
69
|
}
|
|
67
70
|
function nonEmptyString(value) {
|
|
68
71
|
return typeof value === 'string' && value.trim() ? value.trim() : null;
|
|
@@ -75,10 +78,12 @@ function nonEmptyString(value) {
|
|
|
75
78
|
function readServerReleaseInfo(payload, headers) {
|
|
76
79
|
const meta = metaRecord(payload);
|
|
77
80
|
const header = (name) => nonEmptyString(typeof headers?.get === 'function' ? headers.get(name) : null);
|
|
81
|
+
const data = objectRecord(objectRecord(payload)?.data);
|
|
78
82
|
return {
|
|
79
83
|
server_version: nonEmptyString(meta?.server_version) ?? header('X-Dreamstate-Server-Version'),
|
|
80
84
|
minimum_cli_version: nonEmptyString(meta?.minimum_cli_version) ?? header('X-Dreamstate-Minimum-Cli-Version'),
|
|
81
85
|
release_sha: nonEmptyString(meta?.release_sha) ?? header('X-Dreamstate-Release-Sha'),
|
|
86
|
+
registry_hash: nonEmptyString(meta?.registry_hash) ?? nonEmptyString(data?.registry_hash) ?? header('X-Dreamstate-Registry-Hash'),
|
|
82
87
|
};
|
|
83
88
|
}
|
|
84
89
|
function describeVersionSkew(info, cliVersion = exports.CLI_VERSION) {
|
|
@@ -161,24 +166,61 @@ function waitForRetryAfter(value) {
|
|
|
161
166
|
function versionAtMost(current, target) {
|
|
162
167
|
return !isVersionGreater(current, target);
|
|
163
168
|
}
|
|
164
|
-
function
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
169
|
+
function errorEnvelope(payload) {
|
|
170
|
+
return isApiErrorBody(payload) ? payload : null;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* The one parser for an error envelope. request() and the public login
|
|
174
|
+
* requests both use it, so rate-limit receipts, cli_update_required, repair,
|
|
175
|
+
* trace, meta and the idempotency key are not a second copy.
|
|
176
|
+
*/
|
|
177
|
+
function cliErrorFromEnvelope(payload, status, extras = {}) {
|
|
178
|
+
const meta = metaRecord(payload);
|
|
179
|
+
const envelope = errorEnvelope(payload);
|
|
180
|
+
if (envelope) {
|
|
181
|
+
const retryAfterValue = extras.response ? retryAfter(extras.response, envelope) : undefined;
|
|
182
|
+
const repair = envelope.error.repair && typeof envelope.error.repair === 'object' ? { repair: envelope.error.repair } : {};
|
|
183
|
+
if (envelope.error.code === 'cli_update_required') {
|
|
184
|
+
const minimum = extras.info?.minimum_cli_version ?? '';
|
|
185
|
+
const serverDetails = envelope.error.details;
|
|
186
|
+
return new CliError(envelope.error.message, 'cli_update_required', status, {
|
|
187
|
+
details: {
|
|
188
|
+
...(serverDetails && typeof serverDetails === 'object' && !Array.isArray(serverDetails) ? serverDetails : {}),
|
|
189
|
+
...(minimum ? { minimum_cli_version: minimum } : {}),
|
|
190
|
+
cli_version: exports.CLI_VERSION,
|
|
191
|
+
update_command: exports.CLI_UPDATE_COMMAND,
|
|
192
|
+
},
|
|
193
|
+
retryAfter: retryAfterValue,
|
|
194
|
+
traceId: readToolEnvelopeTraceId(payload),
|
|
195
|
+
idempotencyKey: extras.idempotencyKey,
|
|
196
|
+
retryable: false,
|
|
197
|
+
...repair,
|
|
198
|
+
...(meta ? { meta } : {}),
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
const hint = WORKSPACE_ERROR_HINTS[envelope.error.code];
|
|
202
|
+
const serverDetails = envelope.error.details;
|
|
203
|
+
return new CliError(envelope.error.message, envelope.error.code, status, {
|
|
204
|
+
...(hint
|
|
205
|
+
? { details: { ...(serverDetails && typeof serverDetails === 'object' && !Array.isArray(serverDetails) ? serverDetails : {}), cli_hint: hint } }
|
|
206
|
+
: { details: serverDetails }),
|
|
207
|
+
retryAfter: retryAfterValue,
|
|
208
|
+
traceId: readToolEnvelopeTraceId(payload),
|
|
209
|
+
idempotencyKey: extras.idempotencyKey,
|
|
210
|
+
...(typeof envelope.error.retryable === 'boolean' ? { retryable: envelope.error.retryable } : {}),
|
|
211
|
+
...repair,
|
|
212
|
+
...(meta ? { meta } : {}),
|
|
174
213
|
});
|
|
175
214
|
}
|
|
176
215
|
const error = payload && typeof payload === 'object' ? payload.error : null;
|
|
177
|
-
if (error &&
|
|
178
|
-
typeof error === 'object' &&
|
|
179
|
-
typeof error.code === 'string') {
|
|
216
|
+
if (error && typeof error === 'object' && typeof error.code === 'string') {
|
|
180
217
|
const code = error.code;
|
|
181
|
-
|
|
218
|
+
const message = typeof error.message === 'string' ? error.message : code;
|
|
219
|
+
return new CliError(message, code, status, {
|
|
220
|
+
idempotencyKey: extras.idempotencyKey,
|
|
221
|
+
traceId: readToolEnvelopeTraceId(payload),
|
|
222
|
+
...(meta ? { meta } : {}),
|
|
223
|
+
});
|
|
182
224
|
}
|
|
183
225
|
return null;
|
|
184
226
|
}
|
|
@@ -217,7 +259,7 @@ async function requestPublic(baseUrl, path, init) {
|
|
|
217
259
|
catch {
|
|
218
260
|
throw new CliError(`Dreamstate API returned invalid JSON (HTTP ${response.status})`, 'invalid_response', response.status);
|
|
219
261
|
}
|
|
220
|
-
const apiError =
|
|
262
|
+
const apiError = cliErrorFromEnvelope(payload, response.status, { response });
|
|
221
263
|
if (apiError)
|
|
222
264
|
throw apiError;
|
|
223
265
|
if (!response.ok)
|
|
@@ -233,7 +275,7 @@ class DreamstateClient {
|
|
|
233
275
|
workspace;
|
|
234
276
|
requestTimeoutMs;
|
|
235
277
|
onVersionWarning;
|
|
236
|
-
releaseInfo = { server_version: null, minimum_cli_version: null, release_sha: null };
|
|
278
|
+
releaseInfo = { server_version: null, minimum_cli_version: null, release_sha: null, registry_hash: null };
|
|
237
279
|
/** Release identity from the most recent response, success or error. */
|
|
238
280
|
get serverInfo() {
|
|
239
281
|
return { ...this.releaseInfo };
|
|
@@ -310,10 +352,12 @@ class DreamstateClient {
|
|
|
310
352
|
});
|
|
311
353
|
}
|
|
312
354
|
noteServerInfo(info) {
|
|
355
|
+
(0, registryManifest_1.noteRegistryHash)(info.registry_hash);
|
|
313
356
|
this.releaseInfo = {
|
|
314
357
|
server_version: info.server_version ?? this.releaseInfo.server_version,
|
|
315
358
|
minimum_cli_version: info.minimum_cli_version ?? this.releaseInfo.minimum_cli_version,
|
|
316
359
|
release_sha: info.release_sha ?? this.releaseInfo.release_sha,
|
|
360
|
+
registry_hash: info.registry_hash ?? this.releaseInfo.registry_hash,
|
|
317
361
|
};
|
|
318
362
|
}
|
|
319
363
|
async request(path, init = {}, defaultTimeoutMs = exports.DEFAULT_REQUEST_TIMEOUT_MS, allowIncompatibleCli = false) {
|
|
@@ -358,53 +402,18 @@ class DreamstateClient {
|
|
|
358
402
|
const info = readServerReleaseInfo(payload, response.headers);
|
|
359
403
|
this.noteServerInfo(info);
|
|
360
404
|
const meta = metaRecord(payload);
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
retryAfterValue &&
|
|
366
|
-
retryAfterDelayMs(retryAfterValue) !== null) {
|
|
405
|
+
const envelopeError = errorEnvelope(payload);
|
|
406
|
+
if (envelopeError && response.status === 429 && !retriedRateLimit) {
|
|
407
|
+
const retryAfterValue = retryAfter(response, envelopeError);
|
|
408
|
+
if (retryAfterValue && retryAfterDelayMs(retryAfterValue) !== null) {
|
|
367
409
|
retriedRateLimit = true;
|
|
368
410
|
await waitForRetryAfter(retryAfterValue);
|
|
369
411
|
continue;
|
|
370
412
|
}
|
|
371
|
-
if (payload.error.code === 'cli_update_required') {
|
|
372
|
-
// The server refused before executing anything (contract C3). Its own
|
|
373
|
-
// message is kept; the update command rides beside it.
|
|
374
|
-
const minimum = info.minimum_cli_version ?? '';
|
|
375
|
-
throw new CliError(payload.error.message, 'cli_update_required', response.status, {
|
|
376
|
-
details: {
|
|
377
|
-
...(payload.error.details && typeof payload.error.details === 'object' ? payload.error.details : {}),
|
|
378
|
-
...(minimum ? { minimum_cli_version: minimum } : {}),
|
|
379
|
-
cli_version: exports.CLI_VERSION,
|
|
380
|
-
update_command: exports.CLI_UPDATE_COMMAND,
|
|
381
|
-
},
|
|
382
|
-
retryAfter: retryAfterValue,
|
|
383
|
-
traceId: readToolEnvelopeTraceId(payload),
|
|
384
|
-
idempotencyKey,
|
|
385
|
-
retryable: false,
|
|
386
|
-
...(payload.error.repair && typeof payload.error.repair === 'object' ? { repair: payload.error.repair } : {}),
|
|
387
|
-
...(meta ? { meta } : {}),
|
|
388
|
-
});
|
|
389
|
-
}
|
|
390
|
-
const hint = WORKSPACE_ERROR_HINTS[payload.error.code];
|
|
391
|
-
const serverDetails = payload.error.details;
|
|
392
|
-
throw new CliError(payload.error.message, payload.error.code, response.status, {
|
|
393
|
-
...(hint
|
|
394
|
-
? { details: { ...(serverDetails && typeof serverDetails === 'object' && !Array.isArray(serverDetails) ? serverDetails : {}), cli_hint: hint } }
|
|
395
|
-
: { details: serverDetails }),
|
|
396
|
-
retryAfter: retryAfterValue,
|
|
397
|
-
traceId: readToolEnvelopeTraceId(payload),
|
|
398
|
-
idempotencyKey,
|
|
399
|
-
...(typeof payload.error.retryable === 'boolean'
|
|
400
|
-
? { retryable: payload.error.retryable }
|
|
401
|
-
: {}),
|
|
402
|
-
...(payload.error.repair && typeof payload.error.repair === 'object'
|
|
403
|
-
? { repair: payload.error.repair }
|
|
404
|
-
: {}),
|
|
405
|
-
...(meta ? { meta } : {}),
|
|
406
|
-
});
|
|
407
413
|
}
|
|
414
|
+
const parsed = cliErrorFromEnvelope(payload, response.status, { idempotencyKey, response, info });
|
|
415
|
+
if (parsed)
|
|
416
|
+
throw parsed;
|
|
408
417
|
if (!response.ok)
|
|
409
418
|
throw new CliError(`Dreamstate API request failed (HTTP ${response.status})`, 'request_failed', response.status, { idempotencyKey, ...(meta ? { meta } : {}) });
|
|
410
419
|
const minimum = info.minimum_cli_version;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type PackVerbSpec } from './shared';
|
|
2
2
|
import type { CliCommand } from '../index';
|
|
3
|
+
import type { GatedRunContext } from '../gatedRun';
|
|
3
4
|
export declare const SEQUENCE_VERBS: PackVerbSpec[];
|
|
4
5
|
export declare const SEQUENCES_USAGE: string;
|
|
5
6
|
export declare const parseSequencesCommand: (argv: string[]) => CliCommand;
|
|
6
|
-
export declare function runSequencesCommand(context:
|
|
7
|
+
export declare function runSequencesCommand(context: GatedRunContext | undefined, command: CliCommand, stdout: NodeJS.WritableStream): Promise<void>;
|
|
7
8
|
//# sourceMappingURL=sequences.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sequences.d.ts","sourceRoot":"","sources":["../../src/commands/sequences.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"sequences.d.ts","sourceRoot":"","sources":["../../src/commands/sequences.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiE,KAAK,YAAY,EAAE,MAAM,UAAU,CAAC;AAC5G,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAInD,eAAO,MAAM,cAAc,EAAE,YAAY,EAMpC,CAAC;AAEN,eAAO,MAAM,eAAe,QAA+C,CAAC;AAC5E,eAAO,MAAM,qBAAqB,gCAA4E,CAAC;AAC/G,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,eAAe,GAAG,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAQjJ"}
|
|
@@ -1,47 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.parseSequencesCommand = exports.SEQUENCES_USAGE = exports.SEQUENCE_VERBS = void 0;
|
|
4
7
|
exports.runSequencesCommand = runSequencesCommand;
|
|
5
8
|
const shared_1 = require("./shared");
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
{
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
{ verb: 'create', capabilityId: 'workflow.automations.compose' },
|
|
16
|
-
{ verb: 'update', capabilityId: 'workflow.automations.update', positional: automation },
|
|
17
|
-
{ verb: 'lint', capabilityId: 'workflow.automations.lint', positional: automation },
|
|
18
|
-
{ verb: 'preview', capabilityId: 'workflow.automations.preview', positional: automation },
|
|
19
|
-
{ verb: 'variables', capabilityId: 'workflow.automations.variables_list', positional: automation },
|
|
20
|
-
{ verb: 'node-catalog', capabilityId: 'workflow.automations.node_catalog' },
|
|
21
|
-
{ verb: 'node-inspect', capabilityId: 'workflow.automations.node_inspect', positional: [{ name: 'id', into: 'automation_id', optional: true }] },
|
|
22
|
-
{ verb: 'node-add', capabilityId: 'workflow.automations.node_add', positional: automation },
|
|
23
|
-
{ verb: 'node-patch', capabilityId: 'workflow.automations.node_patch', positional: automation },
|
|
24
|
-
{ verb: 'node-remove', capabilityId: 'workflow.automations.node_remove', positional: automation },
|
|
25
|
-
{ verb: 'node-move', capabilityId: 'workflow.automations.node_move', positional: automation },
|
|
26
|
-
{ verb: 'field-options', capabilityId: 'workflow.automations.field_options', positional: [{ name: 'id', into: 'automation_id', optional: true }] },
|
|
27
|
-
{ verb: 'publish', capabilityId: 'sequence.sequences.publish', positional: sequence },
|
|
28
|
-
{ verb: 'enroll', capabilityId: 'sequence.sequences.enroll_selection', positional: sequence },
|
|
29
|
-
{ verb: 'enrollments', capabilityId: 'sequence.sequences.contacts_list', positional: sequence },
|
|
30
|
-
{ verb: 'launch', capabilityId: 'sequence.sequences.launch', positional: sequence },
|
|
31
|
-
{ verb: 'start', capabilityId: 'sequence.sequences.start', positional: sequence },
|
|
32
|
-
{ verb: 'pause', capabilityId: 'sequence.sequences.pause', positional: sequence },
|
|
33
|
-
{ verb: 'resume', capabilityId: 'sequence.sequences.resume', positional: sequence },
|
|
34
|
-
{ verb: 'stats', capabilityId: 'sequence.sequences.step_counts_get', positional: sequence },
|
|
35
|
-
{ verb: 'analytics', capabilityId: 'sequence.sequences.analytics_get', positional: sequence },
|
|
36
|
-
{ verb: 'duplicate', capabilityId: 'workflow.automations.duplicate', positional: automation },
|
|
37
|
-
{ verb: 'archive', capabilityId: 'workflow.automations.archive', positional: automation },
|
|
38
|
-
{ verb: 'export', capabilityId: 'workflow.automations.export', positional: automation },
|
|
39
|
-
{ verb: 'import', capabilityId: 'workflow.automations.import' },
|
|
40
|
-
];
|
|
9
|
+
const errors_1 = require("../errors");
|
|
10
|
+
const packVerbs_generated_json_1 = __importDefault(require("../generated/packVerbs.generated.json"));
|
|
11
|
+
exports.SEQUENCE_VERBS = packVerbs_generated_json_1.default.verbs
|
|
12
|
+
.filter(({ command }) => command.startsWith('sequences '))
|
|
13
|
+
.map(({ command, capabilityId, positional, local }) => ({
|
|
14
|
+
verb: command.slice('sequences '.length), capabilityId,
|
|
15
|
+
...(positional ? { positional } : {}),
|
|
16
|
+
...(local === 'init' ? { local: 'init' } : {}),
|
|
17
|
+
}));
|
|
41
18
|
exports.SEQUENCES_USAGE = (0, shared_1.renderPackUsage)('sequences', exports.SEQUENCE_VERBS);
|
|
42
19
|
exports.parseSequencesCommand = (0, shared_1.buildPackParser)('sequences', 'sequence', exports.SEQUENCE_VERBS, exports.SEQUENCES_USAGE);
|
|
43
20
|
async function runSequencesCommand(context, command, stdout) {
|
|
44
|
-
|
|
45
|
-
|
|
21
|
+
// init writes a local file and calls no API, so it has no gated context.
|
|
22
|
+
if (command.command === 'pack' && command.verb === 'init') {
|
|
23
|
+
(0, shared_1.runPackInit)('sequence', command, stdout);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (!context)
|
|
27
|
+
throw new errors_1.CliUsageError('sequences commands other than init require an authenticated session.');
|
|
46
28
|
await (0, shared_1.runPackCommand)(context, command, stdout);
|
|
47
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/commands/shared.ts"],"names":[],"mappings":"AAKA,OAAO,EAAc,KAAK,UAAU,EAAiC,MAAM,UAAU,CAAC;AAEtF,OAAO,EAA4B,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/commands/shared.ts"],"names":[],"mappings":"AAKA,OAAO,EAAc,KAAK,UAAU,EAAiC,MAAM,UAAU,CAAC;AAEtF,OAAO,EAA4B,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAQ7E,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IACnC;;;;;;OAMG;IACH,UAAU,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,EAAE,CAAC;IAClE,gFAAgF;IAChF,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AA4CD,wBAAgB,eAAe,CAC7B,IAAI,EAAE,WAAW,GAAC,WAAW,EAAE,IAAI,EAAE,UAAU,GAAC,UAAU,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,MAAM,GAC/F,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,UAAU,CAsFhC;AAGD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAKjG;AAED,wBAAgB,WAAW,CACzB,IAAI,EAAE,UAAU,GAAG,UAAU,EAC7B,OAAO,EAAE,UAAU,EACnB,MAAM,EAAE,MAAM,CAAC,cAAc,GAC5B,IAAI,CAuBN;AAYD,wBAAsB,cAAc,CAClC,OAAO,EAAE,eAAe,EACxB,OAAO,EAAE,UAAU,EACnB,MAAM,EAAE,MAAM,CAAC,cAAc,GAC5B,OAAO,CAAC,IAAI,CAAC,CAoDf;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,MAAM,CAK3E"}
|
package/dist/commands/shared.js
CHANGED
|
@@ -15,7 +15,7 @@ const errors_1 = require("../errors");
|
|
|
15
15
|
const gatedRun_1 = require("../gatedRun");
|
|
16
16
|
const node_fs_1 = require("node:fs");
|
|
17
17
|
const runWait_1 = require("../runWait");
|
|
18
|
-
const
|
|
18
|
+
const runContract_1 = require("../runContract");
|
|
19
19
|
function parseObject(raw, flag) {
|
|
20
20
|
try {
|
|
21
21
|
const value = JSON.parse(raw);
|
|
@@ -68,9 +68,9 @@ function takeSchemaFlags(argv, known) {
|
|
|
68
68
|
function parseMode(value) {
|
|
69
69
|
if (value === undefined)
|
|
70
70
|
return undefined;
|
|
71
|
-
if (
|
|
71
|
+
if (runContract_1.RUN_MODES.includes(value))
|
|
72
72
|
return value;
|
|
73
|
-
throw new errors_1.CliUsageError(`--mode must be one of: ${
|
|
73
|
+
throw new errors_1.CliUsageError(`--mode must be one of: ${runContract_1.RUN_MODES.join(', ')}`);
|
|
74
74
|
}
|
|
75
75
|
function buildPackParser(pack, kind, specs, usage) {
|
|
76
76
|
return (argv) => {
|
|
@@ -82,6 +82,7 @@ function buildPackParser(pack, kind, specs, usage) {
|
|
|
82
82
|
const options = {
|
|
83
83
|
mode: { type: 'string' }, 'dry-run': { type: 'boolean' }, live: { type: 'boolean' },
|
|
84
84
|
'idempotency-key': { type: 'string' }, 'max-credits': { type: 'string' }, params: { type: 'string' },
|
|
85
|
+
'max-live-sends': { type: 'string' },
|
|
85
86
|
approved: { type: 'boolean' }, 'approval-id': { type: 'string' }, 'approved-effect-unknown': { type: 'boolean' },
|
|
86
87
|
'quote-hash': { type: 'string' }, 'turn-token': { type: 'string' },
|
|
87
88
|
'wait-timeout': { type: 'string' }, 'no-wait': { type: 'boolean' }, 'json-output': { type: 'boolean' }, open: { type: 'boolean' }, help: { type: 'boolean', short: 'h' },
|
|
@@ -102,8 +103,12 @@ function buildPackParser(pack, kind, specs, usage) {
|
|
|
102
103
|
const dryRun = values['dry-run'];
|
|
103
104
|
const live = values.live;
|
|
104
105
|
const idempotencyKey = values['idempotency-key'];
|
|
106
|
+
if (idempotencyKey !== undefined && idempotencyKey.length > runContract_1.IDEMPOTENCY_KEY_MAX_LENGTH) {
|
|
107
|
+
throw new errors_1.CliUsageError(`--idempotency-key must be at most ${runContract_1.IDEMPOTENCY_KEY_MAX_LENGTH} characters`);
|
|
108
|
+
}
|
|
105
109
|
const rawParams = values.params;
|
|
106
110
|
const rawMaxCredits = values['max-credits'];
|
|
111
|
+
const rawMaxLiveSends = values['max-live-sends'];
|
|
107
112
|
const rawWaitTimeout = values['wait-timeout'];
|
|
108
113
|
if (values.help)
|
|
109
114
|
return { command: 'pack_help', usage, ...(values['json-output'] ? { jsonOutput: true } : {}) };
|
|
@@ -135,8 +140,11 @@ function buildPackParser(pack, kind, specs, usage) {
|
|
|
135
140
|
const maxCredits = rawMaxCredits === undefined ? undefined : Number(rawMaxCredits);
|
|
136
141
|
if (maxCredits !== undefined && (!Number.isFinite(maxCredits) || maxCredits < 0))
|
|
137
142
|
throw new errors_1.CliUsageError('--max-credits must be a non-negative number');
|
|
143
|
+
const maxLiveSends = rawMaxLiveSends === undefined ? undefined : Number(rawMaxLiveSends);
|
|
144
|
+
if (maxLiveSends !== undefined && (!Number.isInteger(maxLiveSends) || maxLiveSends < 1))
|
|
145
|
+
throw new errors_1.CliUsageError('--max-live-sends must be an integer greater than or equal to 1');
|
|
138
146
|
const quoteHash = values['quote-hash'];
|
|
139
|
-
if (quoteHash !== undefined &&
|
|
147
|
+
if (quoteHash !== undefined && !runContract_1.QUOTE_HASH_PATTERN.test(quoteHash))
|
|
140
148
|
throw new errors_1.CliUsageError('--quote-hash must be the sha256:<64 hex> quote_hash a dry run returned');
|
|
141
149
|
const approvalId = values['approval-id'];
|
|
142
150
|
if (approvalId !== undefined && !/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(approvalId))
|
|
@@ -156,6 +164,7 @@ function buildPackParser(pack, kind, specs, usage) {
|
|
|
156
164
|
...(values['turn-token'] ? { turnToken: values['turn-token'] } : {}),
|
|
157
165
|
...(idempotencyKey ? { idempotencyKey } : {}),
|
|
158
166
|
...(maxCredits === undefined ? {} : { maxCredits }), ...(values['json-output'] ? { jsonOutput: true } : {}),
|
|
167
|
+
...(maxLiveSends === undefined ? {} : { maxLiveSends }),
|
|
159
168
|
waitTimeout, ...(values['no-wait'] ? { noWait: true } : {}),
|
|
160
169
|
...(values.open ? { open: true } : {}),
|
|
161
170
|
};
|
|
@@ -168,36 +177,10 @@ function buildPackParser(pack, kind, specs, usage) {
|
|
|
168
177
|
* usefully, rather than to guess a valid sequence on the caller's behalf.
|
|
169
178
|
*/
|
|
170
179
|
function packScaffold(kind, name) {
|
|
171
|
-
//
|
|
172
|
-
// channel/action under `fields` and omitted the id, and the document it wrote was
|
|
173
|
-
// refused by our own lint with `node_contract_unresolved: Node unknown has no
|
|
174
|
-
// canonical node-contract mapping`, because canonicalSequenceStepContractNode reads
|
|
175
|
-
// step.kind and step.action off the step itself. A scaffold whose output the next
|
|
176
|
-
// command in its own printed next_steps rejects is worse than no scaffold.
|
|
180
|
+
// Empty graph. Step and node shapes belong to the server contract, not a second copy here.
|
|
177
181
|
return kind === 'sequence'
|
|
178
|
-
? {
|
|
179
|
-
|
|
180
|
-
name,
|
|
181
|
-
steps: [
|
|
182
|
-
{
|
|
183
|
-
id: 'step_1',
|
|
184
|
-
kind: 'email',
|
|
185
|
-
channel: 'email',
|
|
186
|
-
action: 'send_email',
|
|
187
|
-
subject_template: 'Quick question, {{first_name}}',
|
|
188
|
-
body_template: 'Hi {{first_name}},\n\nWould this be useful to you?',
|
|
189
|
-
},
|
|
190
|
-
],
|
|
191
|
-
}
|
|
192
|
-
: {
|
|
193
|
-
kind: 'workflow',
|
|
194
|
-
name,
|
|
195
|
-
nodes: [
|
|
196
|
-
{ id: 'trigger-root', type: 'trigger', position: { x: 0, y: 0 }, data: { kind: 'trigger', subtype: 'table', config: {} } },
|
|
197
|
-
{ id: 'action-example', type: 'action', position: { x: 0, y: 160 }, data: { kind: 'action', subtype: 'send_connection_request_to_contact', config: {} } },
|
|
198
|
-
],
|
|
199
|
-
edges: [{ id: 'edge-trigger-action', source: 'trigger-root', target: 'action-example' }],
|
|
200
|
-
};
|
|
182
|
+
? { kind: 'sequence', name, steps: [] }
|
|
183
|
+
: { kind: 'workflow', name, nodes: [], edges: [] };
|
|
201
184
|
}
|
|
202
185
|
function runPackInit(kind, command, stdout) {
|
|
203
186
|
if (command.command !== 'pack')
|
|
@@ -254,7 +237,10 @@ async function runPackCommand(context, command, stdout) {
|
|
|
254
237
|
const outcome = await (0, gatedRun_1.runGated)(context, {
|
|
255
238
|
capabilityId: command.capabilityId,
|
|
256
239
|
body: {
|
|
257
|
-
params:
|
|
240
|
+
params: {
|
|
241
|
+
...command.input,
|
|
242
|
+
...(command.maxLiveSends === undefined ? {} : { max_live_sends: command.maxLiveSends }),
|
|
243
|
+
},
|
|
258
244
|
...(command.mode ? { mode: command.mode } : {}),
|
|
259
245
|
...(maxCredits === undefined ? {} : { max_credits: maxCredits }),
|
|
260
246
|
...(command.approved ? { approved: true } : {}),
|
|
@@ -267,16 +253,6 @@ async function runPackCommand(context, command, stdout) {
|
|
|
267
253
|
waitTimeout: command.waitTimeout,
|
|
268
254
|
...(command.noWait ? { noWait: true } : {}),
|
|
269
255
|
coerceParams: true,
|
|
270
|
-
// Bridge for a capability that still lists max_credits among its params (contract C6 keeps
|
|
271
|
-
// the ceiling at the door). The value is copied only while the live schema declares it, so
|
|
272
|
-
// the day the catalog removes the param this stops sending it with no change here.
|
|
273
|
-
adjustParams: (params, capability) => {
|
|
274
|
-
const schema = capability?.input_json_schema;
|
|
275
|
-
const properties = schema && typeof schema === 'object' ? schema.properties : undefined;
|
|
276
|
-
return maxCredits !== undefined && properties && 'max_credits' in properties && params.max_credits === undefined
|
|
277
|
-
? { ...params, max_credits: maxCredits }
|
|
278
|
-
: params;
|
|
279
|
-
},
|
|
280
256
|
});
|
|
281
257
|
const result = outcome.value;
|
|
282
258
|
if (outcome.timedOut)
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type PackVerbSpec } from './shared';
|
|
2
2
|
import type { CliCommand } from '../index';
|
|
3
|
+
import type { GatedRunContext } from '../gatedRun';
|
|
3
4
|
export declare const WORKFLOW_VERBS: PackVerbSpec[];
|
|
4
5
|
export declare const WORKFLOWS_USAGE: string;
|
|
5
6
|
export declare const parseWorkflowsCommand: (argv: string[]) => CliCommand;
|
|
6
|
-
export declare function runWorkflowsCommand(context:
|
|
7
|
+
export declare function runWorkflowsCommand(context: GatedRunContext | undefined, command: CliCommand, stdout: NodeJS.WritableStream): Promise<void>;
|
|
7
8
|
//# sourceMappingURL=workflows.d.ts.map
|