@trydreamstate/cli 1.3.3 → 1.3.5
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 +3 -3
- package/agent-plugin/skills/list-building/SKILL.md +4 -9
- package/agent-plugin/skills/list-building/column-authoring.md +3 -2
- package/agent-plugin/skills/list-building/sourcing.md +2 -2
- package/agent-plugin/skills/outreach/SKILL.md +3 -3
- 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 +9 -3
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +110 -63
- 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 +22 -45
- 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/config.d.ts +5 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +12 -2
- 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 +2 -2
- package/dist/gatedRun.d.ts.map +1 -1
- package/dist/gatedRun.js +157 -60
- 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 +9 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +164 -59
- package/dist/money.d.ts +10 -0
- package/dist/money.d.ts.map +1 -0
- package/dist/money.js +75 -0
- 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 +2 -13
- package/dist/turnCache.d.ts +3 -1
- package/dist/turnCache.d.ts.map +1 -1
- package/dist/turnCache.js +6 -2
- package/package.json +4 -2
|
@@ -6,6 +6,6 @@ Missing connections never block building, editing, saving a draft or validating.
|
|
|
6
6
|
|
|
7
7
|
Enrollment, activation and delivery are different events. Read the result after each one. After an unclear result, check current state before retrying, and never enroll twice or replay an effect that already happened.
|
|
8
8
|
|
|
9
|
-
Preview first. Activation
|
|
9
|
+
Preview first. Activation stores `params.max_credits` on `workflow.workflows.activate`: read exact `required_caps.max_credits` from preview, then resend that value unchanged. This persisted per-delivery ceiling is a declared domain input, not run `max_credits`; put run gating fields at door. Live enrollment takes no send cap: every eligible selected row is enrolled. Never guess it or ask user to approve it.
|
|
10
10
|
|
|
11
11
|
An active worksheet trigger snapshots its saved view on periodic ticks and idempotently enrolls rows that arrive later; draft, paused, and inactive workflows never refill.
|
|
@@ -3,7 +3,7 @@ name: worksheet-tidy
|
|
|
3
3
|
description: "Review a workbook worksheet's structure and values, including duplicate or overlapping columns, column order, types and formatting, columns to hide, criteria and run conditions that never vary, and suspicious values, then apply reversible fixes. Use it when a worksheet has grown messy, before sharing it, or before enrolling it into a sequence. It does not merge CRM records across the workspace, rebuild the list's source (list-building does) or explain failed runs (diagnostics 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 and credits, with no provider prices. If the server asks you to sign in, approve it in the browser.
|
|
7
7
|
|
|
8
8
|
# Worksheet Tidy
|
|
9
9
|
|
|
@@ -59,3 +59,5 @@ Search the workbook tool for each change. The search returns runnable schemas fo
|
|
|
59
59
|
## Check it works
|
|
60
60
|
|
|
61
61
|
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.
|
|
62
|
+
|
|
63
|
+
Paid and outward runs follow the paid-run consent rule.
|
|
@@ -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 and credits, with no provider prices. 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 and credits, with no provider prices. 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;
|
|
@@ -135,6 +137,10 @@ export declare class DreamstateClient {
|
|
|
135
137
|
routePack(goal: string): Promise<unknown>;
|
|
136
138
|
listSkills(query?: Record<string, unknown>): Promise<unknown>;
|
|
137
139
|
searchSkillDocuments(query: Record<string, unknown>): Promise<unknown>;
|
|
140
|
+
/**
|
|
141
|
+
* Every skill, across pages. The route defaults to 20 and caps a page at 50.
|
|
142
|
+
* skills install and skills doctor both call this; one page drops the rest.
|
|
143
|
+
*/
|
|
138
144
|
listAllSkills(): Promise<unknown>;
|
|
139
145
|
getSkill(skillId: string, query?: Record<string, unknown>): Promise<unknown>;
|
|
140
146
|
listTools(query?: Record<string, unknown>): Promise<unknown>;
|
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;IAC/F,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,gBAAgB,CA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M,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,11 +8,15 @@ 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';
|
|
14
15
|
exports.DEFAULT_REQUEST_TIMEOUT_MS = 15_000;
|
|
15
16
|
exports.TOOL_AND_RUN_REQUEST_TIMEOUT_MS = 60_000;
|
|
17
|
+
/** Same ceiling as the server's SKILLS_LIST_MAX_LIMIT. */
|
|
18
|
+
const SKILL_LIST_PAGE_LIMIT = 50;
|
|
19
|
+
const SKILL_LIST_MAX_PAGES = 40;
|
|
16
20
|
/**
|
|
17
21
|
* Next steps for server workspace refusals. The server's message is forwarded
|
|
18
22
|
* unchanged; the CLI's own guidance travels beside it as details.cli_hint, so
|
|
@@ -60,9 +64,11 @@ class CliError extends Error {
|
|
|
60
64
|
}
|
|
61
65
|
}
|
|
62
66
|
exports.CliError = CliError;
|
|
67
|
+
function objectRecord(value) {
|
|
68
|
+
return value && typeof value === 'object' && !Array.isArray(value) ? value : undefined;
|
|
69
|
+
}
|
|
63
70
|
function metaRecord(payload) {
|
|
64
|
-
|
|
65
|
-
return meta && typeof meta === 'object' && !Array.isArray(meta) ? meta : undefined;
|
|
71
|
+
return objectRecord(objectRecord(payload)?.meta);
|
|
66
72
|
}
|
|
67
73
|
function nonEmptyString(value) {
|
|
68
74
|
return typeof value === 'string' && value.trim() ? value.trim() : null;
|
|
@@ -75,10 +81,12 @@ function nonEmptyString(value) {
|
|
|
75
81
|
function readServerReleaseInfo(payload, headers) {
|
|
76
82
|
const meta = metaRecord(payload);
|
|
77
83
|
const header = (name) => nonEmptyString(typeof headers?.get === 'function' ? headers.get(name) : null);
|
|
84
|
+
const data = objectRecord(objectRecord(payload)?.data);
|
|
78
85
|
return {
|
|
79
86
|
server_version: nonEmptyString(meta?.server_version) ?? header('X-Dreamstate-Server-Version'),
|
|
80
87
|
minimum_cli_version: nonEmptyString(meta?.minimum_cli_version) ?? header('X-Dreamstate-Minimum-Cli-Version'),
|
|
81
88
|
release_sha: nonEmptyString(meta?.release_sha) ?? header('X-Dreamstate-Release-Sha'),
|
|
89
|
+
registry_hash: nonEmptyString(meta?.registry_hash) ?? nonEmptyString(data?.registry_hash) ?? header('X-Dreamstate-Registry-Hash'),
|
|
82
90
|
};
|
|
83
91
|
}
|
|
84
92
|
function describeVersionSkew(info, cliVersion = exports.CLI_VERSION) {
|
|
@@ -161,24 +169,61 @@ function waitForRetryAfter(value) {
|
|
|
161
169
|
function versionAtMost(current, target) {
|
|
162
170
|
return !isVersionGreater(current, target);
|
|
163
171
|
}
|
|
164
|
-
function
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
172
|
+
function errorEnvelope(payload) {
|
|
173
|
+
return isApiErrorBody(payload) ? payload : null;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* The one parser for an error envelope. request() and the public login
|
|
177
|
+
* requests both use it, so rate-limit receipts, cli_update_required, repair,
|
|
178
|
+
* trace, meta and the idempotency key are not a second copy.
|
|
179
|
+
*/
|
|
180
|
+
function cliErrorFromEnvelope(payload, status, extras = {}) {
|
|
181
|
+
const meta = metaRecord(payload);
|
|
182
|
+
const envelope = errorEnvelope(payload);
|
|
183
|
+
if (envelope) {
|
|
184
|
+
const retryAfterValue = extras.response ? retryAfter(extras.response, envelope) : undefined;
|
|
185
|
+
const repair = envelope.error.repair && typeof envelope.error.repair === 'object' ? { repair: envelope.error.repair } : {};
|
|
186
|
+
if (envelope.error.code === 'cli_update_required') {
|
|
187
|
+
const minimum = extras.info?.minimum_cli_version ?? '';
|
|
188
|
+
const serverDetails = envelope.error.details;
|
|
189
|
+
return new CliError(envelope.error.message, 'cli_update_required', status, {
|
|
190
|
+
details: {
|
|
191
|
+
...(serverDetails && typeof serverDetails === 'object' && !Array.isArray(serverDetails) ? serverDetails : {}),
|
|
192
|
+
...(minimum ? { minimum_cli_version: minimum } : {}),
|
|
193
|
+
cli_version: exports.CLI_VERSION,
|
|
194
|
+
update_command: exports.CLI_UPDATE_COMMAND,
|
|
195
|
+
},
|
|
196
|
+
retryAfter: retryAfterValue,
|
|
197
|
+
traceId: readToolEnvelopeTraceId(payload),
|
|
198
|
+
idempotencyKey: extras.idempotencyKey,
|
|
199
|
+
retryable: false,
|
|
200
|
+
...repair,
|
|
201
|
+
...(meta ? { meta } : {}),
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
const hint = WORKSPACE_ERROR_HINTS[envelope.error.code];
|
|
205
|
+
const serverDetails = envelope.error.details;
|
|
206
|
+
return new CliError(envelope.error.message, envelope.error.code, status, {
|
|
207
|
+
...(hint
|
|
208
|
+
? { details: { ...(serverDetails && typeof serverDetails === 'object' && !Array.isArray(serverDetails) ? serverDetails : {}), cli_hint: hint } }
|
|
209
|
+
: { details: serverDetails }),
|
|
210
|
+
retryAfter: retryAfterValue,
|
|
211
|
+
traceId: readToolEnvelopeTraceId(payload),
|
|
212
|
+
idempotencyKey: extras.idempotencyKey,
|
|
213
|
+
...(typeof envelope.error.retryable === 'boolean' ? { retryable: envelope.error.retryable } : {}),
|
|
214
|
+
...repair,
|
|
215
|
+
...(meta ? { meta } : {}),
|
|
174
216
|
});
|
|
175
217
|
}
|
|
176
218
|
const error = payload && typeof payload === 'object' ? payload.error : null;
|
|
177
|
-
if (error &&
|
|
178
|
-
typeof error === 'object' &&
|
|
179
|
-
typeof error.code === 'string') {
|
|
219
|
+
if (error && typeof error === 'object' && typeof error.code === 'string') {
|
|
180
220
|
const code = error.code;
|
|
181
|
-
|
|
221
|
+
const message = typeof error.message === 'string' ? error.message : code;
|
|
222
|
+
return new CliError(message, code, status, {
|
|
223
|
+
idempotencyKey: extras.idempotencyKey,
|
|
224
|
+
traceId: readToolEnvelopeTraceId(payload),
|
|
225
|
+
...(meta ? { meta } : {}),
|
|
226
|
+
});
|
|
182
227
|
}
|
|
183
228
|
return null;
|
|
184
229
|
}
|
|
@@ -217,7 +262,7 @@ async function requestPublic(baseUrl, path, init) {
|
|
|
217
262
|
catch {
|
|
218
263
|
throw new CliError(`Dreamstate API returned invalid JSON (HTTP ${response.status})`, 'invalid_response', response.status);
|
|
219
264
|
}
|
|
220
|
-
const apiError =
|
|
265
|
+
const apiError = cliErrorFromEnvelope(payload, response.status, { response });
|
|
221
266
|
if (apiError)
|
|
222
267
|
throw apiError;
|
|
223
268
|
if (!response.ok)
|
|
@@ -233,7 +278,7 @@ class DreamstateClient {
|
|
|
233
278
|
workspace;
|
|
234
279
|
requestTimeoutMs;
|
|
235
280
|
onVersionWarning;
|
|
236
|
-
releaseInfo = { server_version: null, minimum_cli_version: null, release_sha: null };
|
|
281
|
+
releaseInfo = { server_version: null, minimum_cli_version: null, release_sha: null, registry_hash: null };
|
|
237
282
|
/** Release identity from the most recent response, success or error. */
|
|
238
283
|
get serverInfo() {
|
|
239
284
|
return { ...this.releaseInfo };
|
|
@@ -270,8 +315,43 @@ class DreamstateClient {
|
|
|
270
315
|
searchSkillDocuments(query) {
|
|
271
316
|
return this.request(`/skills/search${queryString(query)}`);
|
|
272
317
|
}
|
|
273
|
-
|
|
274
|
-
|
|
318
|
+
/**
|
|
319
|
+
* Every skill, across pages. The route defaults to 20 and caps a page at 50.
|
|
320
|
+
* skills install and skills doctor both call this; one page drops the rest.
|
|
321
|
+
*/
|
|
322
|
+
async listAllSkills() {
|
|
323
|
+
const pages = [];
|
|
324
|
+
const seenCursors = new Set();
|
|
325
|
+
const seenIds = new Set();
|
|
326
|
+
let cursor;
|
|
327
|
+
let last;
|
|
328
|
+
for (let page = 0; page < SKILL_LIST_MAX_PAGES; page += 1) {
|
|
329
|
+
last = await this.listSkills({ limit: SKILL_LIST_PAGE_LIMIT, ...(cursor ? { cursor } : {}) });
|
|
330
|
+
const data = last && typeof last === 'object' ? last.data : undefined;
|
|
331
|
+
const record = data && typeof data === 'object' ? data : null;
|
|
332
|
+
if (!record || !Array.isArray(record.skills))
|
|
333
|
+
return last;
|
|
334
|
+
const skills = record.skills;
|
|
335
|
+
for (const skill of skills) {
|
|
336
|
+
const id = skill && typeof skill === 'object' ? skill.id : undefined;
|
|
337
|
+
if (typeof id === 'string') {
|
|
338
|
+
if (seenIds.has(id))
|
|
339
|
+
continue;
|
|
340
|
+
seenIds.add(id);
|
|
341
|
+
}
|
|
342
|
+
pages.push(skill);
|
|
343
|
+
}
|
|
344
|
+
const next = typeof record.next_cursor === 'string' ? record.next_cursor.trim() : '';
|
|
345
|
+
if (!next) {
|
|
346
|
+
return { ...last, data: { ...record, skills: pages, next_cursor: null } };
|
|
347
|
+
}
|
|
348
|
+
if (seenCursors.has(next)) {
|
|
349
|
+
throw new CliError('Dreamstate API repeated a skill list cursor.', 'invalid_response', 200);
|
|
350
|
+
}
|
|
351
|
+
seenCursors.add(next);
|
|
352
|
+
cursor = next;
|
|
353
|
+
}
|
|
354
|
+
throw new CliError('Dreamstate API skill list did not end.', 'invalid_response', 200);
|
|
275
355
|
}
|
|
276
356
|
getSkill(skillId, query = {}) {
|
|
277
357
|
return this.request(`/skills/${encodeURIComponent(skillId)}${queryString(query)}`);
|
|
@@ -310,10 +390,12 @@ class DreamstateClient {
|
|
|
310
390
|
});
|
|
311
391
|
}
|
|
312
392
|
noteServerInfo(info) {
|
|
393
|
+
(0, registryManifest_1.noteRegistryHash)(info.registry_hash);
|
|
313
394
|
this.releaseInfo = {
|
|
314
395
|
server_version: info.server_version ?? this.releaseInfo.server_version,
|
|
315
396
|
minimum_cli_version: info.minimum_cli_version ?? this.releaseInfo.minimum_cli_version,
|
|
316
397
|
release_sha: info.release_sha ?? this.releaseInfo.release_sha,
|
|
398
|
+
registry_hash: info.registry_hash ?? this.releaseInfo.registry_hash,
|
|
317
399
|
};
|
|
318
400
|
}
|
|
319
401
|
async request(path, init = {}, defaultTimeoutMs = exports.DEFAULT_REQUEST_TIMEOUT_MS, allowIncompatibleCli = false) {
|
|
@@ -342,7 +424,7 @@ class DreamstateClient {
|
|
|
342
424
|
if (controller.signal.aborted) {
|
|
343
425
|
throw new CliError(errors_1.CLI_LOCAL_ERROR_CODES.request_timeout, 'request_timeout', 0, { idempotencyKey, repair: errors_1.CLI_LOCAL_ERROR_REPAIRS.request_timeout });
|
|
344
426
|
}
|
|
345
|
-
throw new CliError(`Request failed: ${error instanceof Error ? error.message : String(error)}`, 'network_error', 0, { repair: errors_1.CLI_LOCAL_ERROR_REPAIRS.network_error });
|
|
427
|
+
throw new CliError(`Request failed: ${error instanceof Error ? error.message : String(error)}`, 'network_error', 0, { idempotencyKey, repair: errors_1.CLI_LOCAL_ERROR_REPAIRS.network_error });
|
|
346
428
|
}
|
|
347
429
|
finally {
|
|
348
430
|
clearTimeout(timeout);
|
|
@@ -358,53 +440,18 @@ class DreamstateClient {
|
|
|
358
440
|
const info = readServerReleaseInfo(payload, response.headers);
|
|
359
441
|
this.noteServerInfo(info);
|
|
360
442
|
const meta = metaRecord(payload);
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
retryAfterValue &&
|
|
366
|
-
retryAfterDelayMs(retryAfterValue) !== null) {
|
|
443
|
+
const envelopeError = errorEnvelope(payload);
|
|
444
|
+
if (envelopeError && response.status === 429 && !retriedRateLimit) {
|
|
445
|
+
const retryAfterValue = retryAfter(response, envelopeError);
|
|
446
|
+
if (retryAfterValue && retryAfterDelayMs(retryAfterValue) !== null) {
|
|
367
447
|
retriedRateLimit = true;
|
|
368
448
|
await waitForRetryAfter(retryAfterValue);
|
|
369
449
|
continue;
|
|
370
450
|
}
|
|
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
451
|
}
|
|
452
|
+
const parsed = cliErrorFromEnvelope(payload, response.status, { idempotencyKey, response, info });
|
|
453
|
+
if (parsed)
|
|
454
|
+
throw parsed;
|
|
408
455
|
if (!response.ok)
|
|
409
456
|
throw new CliError(`Dreamstate API request failed (HTTP ${response.status})`, 'request_failed', response.status, { idempotencyKey, ...(meta ? { meta } : {}) });
|
|
410
457
|
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,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