@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
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.
|
|
4
|
+
exports.capabilityIdempotencyKey = exports.CliUsageError = exports.CLI_EXIT = void 0;
|
|
5
5
|
exports.parseCliArgs = parseCliArgs;
|
|
6
6
|
exports.refusalEnvelope = refusalEnvelope;
|
|
7
7
|
exports.openWebUrl = openWebUrl;
|
|
@@ -27,12 +27,10 @@ Object.defineProperty(exports, "CLI_EXIT", { enumerable: true, get: function ()
|
|
|
27
27
|
Object.defineProperty(exports, "CliUsageError", { enumerable: true, get: function () { return errors_1.CliUsageError; } });
|
|
28
28
|
const gatedRun_1 = require("./gatedRun");
|
|
29
29
|
Object.defineProperty(exports, "capabilityIdempotencyKey", { enumerable: true, get: function () { return gatedRun_1.capabilityIdempotencyKey; } });
|
|
30
|
-
Object.defineProperty(exports, "omitsToolTurnForInlineTableRead", { enumerable: true, get: function () { return gatedRun_1.omitsToolTurnForInlineTableRead; } });
|
|
31
|
-
Object.defineProperty(exports, "toolTurnToken", { enumerable: true, get: function () { return gatedRun_1.toolTurnToken; } });
|
|
32
30
|
const tablesImport_1 = require("./tablesImport");
|
|
33
31
|
const commandTable_1 = require("./commandTable");
|
|
34
32
|
const skillInstaller_1 = require("./skillInstaller");
|
|
35
|
-
const
|
|
33
|
+
const runContract_1 = require("./runContract");
|
|
36
34
|
const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
37
35
|
const USAGE = `Dreamstate CLI
|
|
38
36
|
|
|
@@ -61,7 +59,7 @@ Usage:
|
|
|
61
59
|
dreamstate commands search <term> [--json-output|--json]
|
|
62
60
|
dreamstate tools search --goal <goal> [--terms <csv>] [--limit <n>] [--toolset <pack_id>] [--json-output|--json]
|
|
63
61
|
dreamstate tools get <capability_id> [--json-output|--json]
|
|
64
|
-
dreamstate tools run <capability_id> [--params <object>|--json <body>] [--turn-token <token>] (--live | --dry-run | --mode <smoke_test|dry_run|live>) [--approved] [--approval-id <uuid>] [--approved-effect-unknown] [--max-credits <n>] [--quote-hash <sha256:...>] [--idempotency-key <key>] [--wait-timeout <seconds>] [--no-wait] [--open] [--json-output
|
|
62
|
+
dreamstate tools run <capability_id> [--params <object>|--json <body>] [--turn-token <token>] (--live | --dry-run | --mode <smoke_test|dry_run|live>) [--approved] [--approval-id <uuid>] [--approved-effect-unknown] [--max-credits <n>] [--max-live-sends <n>] [--quote-hash <sha256:...>] [--idempotency-key <key>] [--wait-timeout <seconds>] [--no-wait] [--open] [--json-output]
|
|
65
63
|
dreamstate sequences <verb> [args] [flags]
|
|
66
64
|
dreamstate workflows <verb> [args] [flags]
|
|
67
65
|
dreamstate tables import --table-id <uuid> --file <path> [--format <csv|json|jsonl|xlsx>] [--preview] [--upsert-key <header>] [--row-kind <person|company>] [--keep-unmapped-columns <true|false>] [--json-output|--json]
|
|
@@ -72,7 +70,7 @@ Usage:
|
|
|
72
70
|
|
|
73
71
|
All catalog discovery reads live API records. Set DREAMSTATE_API_URL and DREAMSTATE_API_KEY.
|
|
74
72
|
Run responses wait for terminal run status by default, timeout default is 120 seconds, --no-wait returns immediate response. Timeout prints latest run envelope and exits ${runWait_1.RUN_WAIT_TIMEOUT_EXIT_CODE}.
|
|
75
|
-
A write you re-run unchanged presents the same Idempotency-Key (printed as meta.idempotency_key), so the server replays instead of running it twice; --idempotency-key sets one yourself. Exit codes: 0 ok, 2 usage, 3 auth, 4 not found, 5 server failure, 6 rate limited, 7
|
|
73
|
+
A write you re-run unchanged presents the same Idempotency-Key (printed as meta.idempotency_key), so the server replays instead of running it twice; --idempotency-key sets one yourself. Exit codes: 0 ok, 2 usage, 3 auth, 4 not found, 5 server failure, 6 rate limited, 7 repair.kind ask_user, 8 CLI update required, 9 refused, 10 transport, 11 timeout.
|
|
76
74
|
login opens browser approval and installs Dreamstate skills for detected agents; --no-skills skips installation. login --token stores a ds_user_ session or ds_live_ key (for SSH or remote machines) after verifying it with whoami.
|
|
77
75
|
Global flag --workspace <id|slug> (any command) or DREAMSTATE_WORKSPACE picks the workspace for one call; workspaces use stores a default. Flag beats env beats stored. A ds_live_ key is bound to one workspace and cannot switch.
|
|
78
76
|
logout deletes the stored credentials file. --agents takes space-separated, comma-separated or repeated values.
|
|
@@ -103,7 +101,7 @@ function csv(raw, flag = '--terms') {
|
|
|
103
101
|
return [...new Set(values)];
|
|
104
102
|
}
|
|
105
103
|
function requireToolsRunMode(body) {
|
|
106
|
-
if (
|
|
104
|
+
if (runContract_1.RUN_MODES.includes(body.mode))
|
|
107
105
|
return;
|
|
108
106
|
throw new errors_1.CliUsageError('mode must be one of: smoke_test, dry_run, live.');
|
|
109
107
|
}
|
|
@@ -119,6 +117,12 @@ function nonNegativeInteger(raw, flag) {
|
|
|
119
117
|
throw new errors_1.CliUsageError(`${flag} must be a non-negative integer`);
|
|
120
118
|
return value;
|
|
121
119
|
}
|
|
120
|
+
function positiveInteger(raw, flag) {
|
|
121
|
+
const value = Number(raw);
|
|
122
|
+
if (!Number.isSafeInteger(value) || value < 1)
|
|
123
|
+
throw new errors_1.CliUsageError(`${flag} must be an integer greater than or equal to 1`);
|
|
124
|
+
return value;
|
|
125
|
+
}
|
|
122
126
|
// runs.get returns { data: { run: { state_version } } }. Cancel posts
|
|
123
127
|
// expected_state_version, and a missing read must not invent 0.
|
|
124
128
|
function stateVersionFromRunRead(payload) {
|
|
@@ -225,8 +229,8 @@ function toolsRunMode(values) {
|
|
|
225
229
|
chosen.add('live');
|
|
226
230
|
if (values.mode !== undefined) {
|
|
227
231
|
const mode = values.mode.trim();
|
|
228
|
-
if (!
|
|
229
|
-
throw new errors_1.CliUsageError(`--mode must be one of: ${
|
|
232
|
+
if (!runContract_1.RUN_MODES.includes(mode)) {
|
|
233
|
+
throw new errors_1.CliUsageError(`--mode must be one of: ${runContract_1.RUN_MODES.join(', ')}`);
|
|
230
234
|
}
|
|
231
235
|
chosen.add(mode);
|
|
232
236
|
}
|
|
@@ -243,7 +247,7 @@ function parseTools(argv) {
|
|
|
243
247
|
'dry-run': { type: 'boolean' }, live: { type: 'boolean' }, mode: { type: 'string' },
|
|
244
248
|
approved: { type: 'boolean' }, 'approved-effect-unknown': { type: 'boolean' },
|
|
245
249
|
'quote-hash': { type: 'string' }, 'approval-id': { type: 'string' },
|
|
246
|
-
'max-credits': { type: 'string' }, 'turn-token': { type: 'string' }, 'wait-timeout': { type: 'string' }, 'no-wait': { type: 'boolean' }, help: { type: 'boolean', short: 'h' },
|
|
250
|
+
'max-credits': { type: 'string' }, 'max-live-sends': { type: 'string' }, 'turn-token': { type: 'string' }, 'wait-timeout': { type: 'string' }, 'no-wait': { type: 'boolean' }, help: { type: 'boolean', short: 'h' },
|
|
247
251
|
}, allowPositionals: true, strict: true });
|
|
248
252
|
if (values.help)
|
|
249
253
|
return { command: 'help' };
|
|
@@ -293,8 +297,17 @@ function parseTools(argv) {
|
|
|
293
297
|
body.approved_effect_unknown = true;
|
|
294
298
|
if (values['max-credits'] !== undefined)
|
|
295
299
|
body.max_credits = nonNegativeNumber(values['max-credits'], '--max-credits');
|
|
300
|
+
if (body.max_live_sends !== undefined) {
|
|
301
|
+
throw new errors_1.CliUsageError('max_live_sends is a capability parameter. Put it in params.max_live_sends or pass --max-live-sends.');
|
|
302
|
+
}
|
|
303
|
+
if (values['max-live-sends'] !== undefined) {
|
|
304
|
+
const params = body.params;
|
|
305
|
+
if (!params || typeof params !== 'object' || Array.isArray(params))
|
|
306
|
+
throw new errors_1.CliUsageError('tools run params must be an object');
|
|
307
|
+
params.max_live_sends = positiveInteger(values['max-live-sends'], '--max-live-sends');
|
|
308
|
+
}
|
|
296
309
|
if (values['quote-hash'] !== undefined) {
|
|
297
|
-
if (
|
|
310
|
+
if (!runContract_1.QUOTE_HASH_PATTERN.test(values['quote-hash']))
|
|
298
311
|
throw new errors_1.CliUsageError('--quote-hash must be the sha256:<64 hex> quote_hash a dry run returned');
|
|
299
312
|
body.quote_hash = values['quote-hash'];
|
|
300
313
|
}
|
|
@@ -317,6 +330,9 @@ function parseTools(argv) {
|
|
|
317
330
|
if (body.mode !== undefined)
|
|
318
331
|
requireToolsRunMode(body);
|
|
319
332
|
const waitTimeout = values['wait-timeout'] === undefined ? 120 : nonNegativeNumber(values['wait-timeout'], '--wait-timeout');
|
|
333
|
+
if (values['idempotency-key'] !== undefined && values['idempotency-key'].length > runContract_1.IDEMPOTENCY_KEY_MAX_LENGTH) {
|
|
334
|
+
throw new errors_1.CliUsageError(`--idempotency-key must be at most ${runContract_1.IDEMPOTENCY_KEY_MAX_LENGTH} characters`);
|
|
335
|
+
}
|
|
320
336
|
return { command: 'tools_run', capabilityId, body, waitTimeout, ...(values['no-wait'] ? { noWait: true } : {}), ...(values['turn-token'] ? { turnToken: values['turn-token'] } : {}), ...(values['idempotency-key'] ? { idempotencyKey: values['idempotency-key'] } : {}), ...(values.open ? { open: true } : {}), ...output };
|
|
321
337
|
}
|
|
322
338
|
throw new errors_1.CliUsageError('Usage: dreamstate tools <search|get|run>');
|
|
@@ -421,6 +437,12 @@ function parseRuns(argv) {
|
|
|
421
437
|
}
|
|
422
438
|
throw new errors_1.CliUsageError('Usage: dreamstate runs <list|get|events|cancel> <run_id>');
|
|
423
439
|
}
|
|
440
|
+
function sequencesCommands() {
|
|
441
|
+
return require('./commands/sequences');
|
|
442
|
+
}
|
|
443
|
+
function workflowsCommands() {
|
|
444
|
+
return require('./commands/workflows');
|
|
445
|
+
}
|
|
424
446
|
function normalizeJsonOutputAlias(argv) {
|
|
425
447
|
return argv.map((argument, index) => argument === '--json' && (index === argv.length - 1 || argv[index + 1]?.startsWith('-'))
|
|
426
448
|
? '--json-output'
|
|
@@ -521,9 +543,9 @@ function parseCliArgs(argv) {
|
|
|
521
543
|
if (group === 'runs')
|
|
522
544
|
return parseRuns(rest);
|
|
523
545
|
if (group === 'sequences')
|
|
524
|
-
return
|
|
546
|
+
return sequencesCommands().parseSequencesCommand(rest);
|
|
525
547
|
if (group === 'workflows')
|
|
526
|
-
return
|
|
548
|
+
return workflowsCommands().parseWorkflowsCommand(rest);
|
|
527
549
|
throw new errors_1.CliUsageError(`Unknown command: ${group}`);
|
|
528
550
|
}
|
|
529
551
|
function print(value, stdout, compact) {
|
|
@@ -721,12 +743,16 @@ function exitCodeForError(error) {
|
|
|
721
743
|
// "a person has to decide", and an update-required refusal is 426.
|
|
722
744
|
if (errorCode === 'cli_update_required')
|
|
723
745
|
return errors_1.CLI_EXIT.UPDATE_REQUIRED;
|
|
724
|
-
|
|
725
|
-
|
|
746
|
+
// Local transport failures stamp repair.kind ask_user (read the target back,
|
|
747
|
+
// then ask a person). Their published exits win over that repair.
|
|
726
748
|
if (errorCode === 'request_timeout')
|
|
727
749
|
return errors_1.CLI_EXIT.TIMEOUT;
|
|
750
|
+
if (errorCode === 'network_error')
|
|
751
|
+
return errors_1.CLI_EXIT.TRANSPORT;
|
|
728
752
|
if ((0, errors_1.isLocalRefusalCode)(errorCode))
|
|
729
753
|
return errors_1.CLI_EXIT.REFUSED;
|
|
754
|
+
if ((0, errors_1.isApprovalRepair)(error))
|
|
755
|
+
return errors_1.CLI_EXIT.APPROVAL;
|
|
730
756
|
const status = error instanceof client_1.CliError ? error.status : 0;
|
|
731
757
|
if (status === 401 || status === 403)
|
|
732
758
|
return errors_1.CLI_EXIT.AUTH;
|
|
@@ -734,8 +760,6 @@ function exitCodeForError(error) {
|
|
|
734
760
|
return errors_1.CLI_EXIT.NOT_FOUND;
|
|
735
761
|
if (status === 429)
|
|
736
762
|
return errors_1.CLI_EXIT.RATE_LIMITED;
|
|
737
|
-
if (errorCode === 'network_error')
|
|
738
|
-
return errors_1.CLI_EXIT.TRANSPORT;
|
|
739
763
|
if (status >= 500 || errorCode === 'invalid_response')
|
|
740
764
|
return errors_1.CLI_EXIT.SERVER;
|
|
741
765
|
if (status >= 400)
|
|
@@ -804,16 +828,15 @@ function whoamiData(value) {
|
|
|
804
828
|
* "unknown", never "compatible".
|
|
805
829
|
*/
|
|
806
830
|
function statusData(whoami, health, info) {
|
|
807
|
-
|
|
808
|
-
const
|
|
809
|
-
const
|
|
810
|
-
const resolved = { ...info, server_version: serverVersion };
|
|
811
|
-
const skew = (0, client_1.describeVersionSkew)(resolved);
|
|
831
|
+
// health.data.version is not the release. server_version comes only from envelope meta.
|
|
832
|
+
const serverVersion = info.server_version;
|
|
833
|
+
const skew = (0, client_1.describeVersionSkew)(info);
|
|
812
834
|
const compatible = skew !== 'cli_below_minimum';
|
|
813
835
|
return {
|
|
814
836
|
cli_version: client_1.CLI_VERSION,
|
|
815
837
|
api_version: serverVersion,
|
|
816
838
|
server_version: serverVersion,
|
|
839
|
+
registry_hash: info.registry_hash,
|
|
817
840
|
release_sha: info.release_sha,
|
|
818
841
|
minimum_cli_version: info.minimum_cli_version,
|
|
819
842
|
minimum_cli_version_published: info.minimum_cli_version !== null,
|
|
@@ -1168,12 +1191,10 @@ async function runCli(argv = process.argv.slice(2), runtime = {}) {
|
|
|
1168
1191
|
// Resolving credentials first would refuse it with not_authenticated.
|
|
1169
1192
|
if (command.command === 'pack' && command.verb === 'init') {
|
|
1170
1193
|
if (command.pack === 'sequences') {
|
|
1171
|
-
await
|
|
1172
|
-
.runSequencesCommand(undefined, command, stdout);
|
|
1194
|
+
await sequencesCommands().runSequencesCommand(undefined, command, stdout);
|
|
1173
1195
|
}
|
|
1174
1196
|
else {
|
|
1175
|
-
await
|
|
1176
|
-
.runWorkflowsCommand(undefined, command, stdout);
|
|
1197
|
+
await workflowsCommands().runWorkflowsCommand(undefined, command, stdout);
|
|
1177
1198
|
}
|
|
1178
1199
|
process.exitCode = errors_1.CLI_EXIT.SUCCESS;
|
|
1179
1200
|
return;
|
|
@@ -1366,10 +1387,10 @@ async function runCli(argv = process.argv.slice(2), runtime = {}) {
|
|
|
1366
1387
|
}
|
|
1367
1388
|
case 'pack': {
|
|
1368
1389
|
if (command.pack === 'sequences') {
|
|
1369
|
-
await
|
|
1390
|
+
await sequencesCommands().runSequencesCommand(gatedContext(), command, stdout);
|
|
1370
1391
|
}
|
|
1371
1392
|
else {
|
|
1372
|
-
await
|
|
1393
|
+
await workflowsCommands().runWorkflowsCommand(gatedContext(), command, stdout);
|
|
1373
1394
|
}
|
|
1374
1395
|
return;
|
|
1375
1396
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CapabilityPosture } from './capabilityPosture';
|
|
2
|
+
export declare function lookupPosture(capabilityId: string): CapabilityPosture | null;
|
|
3
|
+
export declare function rememberPosture(capabilityId: string, posture: CapabilityPosture): void;
|
|
4
|
+
/** Records the hash from a response. A change clears cached postures. */
|
|
5
|
+
export declare function noteRegistryHash(hash: string | null): void;
|
|
6
|
+
//# sourceMappingURL=registryManifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registryManifest.d.ts","sourceRoot":"","sources":["../src/registryManifest.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAuD7D,wBAAgB,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,iBAAiB,GAAG,IAAI,CAE5E;AAED,wBAAgB,eAAe,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,IAAI,CAItF;AAED,yEAAyE;AACzE,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAK1D"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.lookupPosture = lookupPosture;
|
|
4
|
+
exports.rememberPosture = rememberPosture;
|
|
5
|
+
exports.noteRegistryHash = noteRegistryHash;
|
|
6
|
+
const node_fs_1 = require("node:fs");
|
|
7
|
+
const node_os_1 = require("node:os");
|
|
8
|
+
const node_path_1 = require("node:path");
|
|
9
|
+
function manifestPath(home = (0, node_os_1.homedir)()) {
|
|
10
|
+
return (0, node_path_1.join)(home, '.dreamstate', 'registry-manifest.json');
|
|
11
|
+
}
|
|
12
|
+
function empty() {
|
|
13
|
+
return { registry_hash: null, postures: {} };
|
|
14
|
+
}
|
|
15
|
+
function readManifest() {
|
|
16
|
+
try {
|
|
17
|
+
const parsed = JSON.parse((0, node_fs_1.readFileSync)(manifestPath(), 'utf8'));
|
|
18
|
+
const root = parsed && typeof parsed === 'object' && !Array.isArray(parsed) ? parsed : null;
|
|
19
|
+
if (!root)
|
|
20
|
+
return empty();
|
|
21
|
+
const postures = {};
|
|
22
|
+
const raw = root.postures && typeof root.postures === 'object' && !Array.isArray(root.postures)
|
|
23
|
+
? root.postures
|
|
24
|
+
: {};
|
|
25
|
+
for (const [id, value] of Object.entries(raw)) {
|
|
26
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
27
|
+
continue;
|
|
28
|
+
const posture = value;
|
|
29
|
+
postures[id] = { inlineRead: posture.inlineRead === true, returnsRunId: posture.returnsRunId === true };
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
registry_hash: typeof root.registry_hash === 'string' && root.registry_hash ? root.registry_hash : null,
|
|
33
|
+
postures,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return empty();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function writeManifest(manifest) {
|
|
41
|
+
try {
|
|
42
|
+
const path = manifestPath();
|
|
43
|
+
(0, node_fs_1.mkdirSync)((0, node_path_1.dirname)(path), { recursive: true });
|
|
44
|
+
(0, node_fs_1.writeFileSync)(path, `${JSON.stringify(manifest)}\n`, 'utf8');
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
// Cache only. A request still runs when the home directory is not writable.
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function lookupPosture(capabilityId) {
|
|
51
|
+
return readManifest().postures[capabilityId] ?? null;
|
|
52
|
+
}
|
|
53
|
+
function rememberPosture(capabilityId, posture) {
|
|
54
|
+
const manifest = readManifest();
|
|
55
|
+
manifest.postures[capabilityId] = posture;
|
|
56
|
+
writeManifest(manifest);
|
|
57
|
+
}
|
|
58
|
+
/** Records the hash from a response. A change clears cached postures. */
|
|
59
|
+
function noteRegistryHash(hash) {
|
|
60
|
+
if (!hash)
|
|
61
|
+
return;
|
|
62
|
+
const manifest = readManifest();
|
|
63
|
+
if (manifest.registry_hash === hash)
|
|
64
|
+
return;
|
|
65
|
+
writeManifest({ registry_hash: hash, postures: manifest.registry_hash ? {} : manifest.postures });
|
|
66
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run-door constants. Frozen names are RUN_MODES, QUOTE_HASH_PATTERN and
|
|
3
|
+
* IDEMPOTENCY_KEY_MAX_LENGTH. The source is packages/types/src/agentSurface.ts.
|
|
4
|
+
* The published CLI cannot depend on the unpublished types package, so the
|
|
5
|
+
* values are generated into src/generated/runContract.generated.ts.
|
|
6
|
+
*/
|
|
7
|
+
import { IDEMPOTENCY_KEY_MAX_LENGTH, QUOTE_HASH_PATTERN, RUN_MODES } from './generated/runContract.generated';
|
|
8
|
+
export { IDEMPOTENCY_KEY_MAX_LENGTH, QUOTE_HASH_PATTERN, RUN_MODES };
|
|
9
|
+
export type RunMode = (typeof RUN_MODES)[number];
|
|
10
|
+
//# sourceMappingURL=runContract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runContract.d.ts","sourceRoot":"","sources":["../src/runContract.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,0BAA0B,EAC1B,kBAAkB,EAClB,SAAS,EACV,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,SAAS,EAAE,CAAC;AACrE,MAAM,MAAM,OAAO,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RUN_MODES = exports.QUOTE_HASH_PATTERN = exports.IDEMPOTENCY_KEY_MAX_LENGTH = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Run-door constants. Frozen names are RUN_MODES, QUOTE_HASH_PATTERN and
|
|
6
|
+
* IDEMPOTENCY_KEY_MAX_LENGTH. The source is packages/types/src/agentSurface.ts.
|
|
7
|
+
* The published CLI cannot depend on the unpublished types package, so the
|
|
8
|
+
* values are generated into src/generated/runContract.generated.ts.
|
|
9
|
+
*/
|
|
10
|
+
const runContract_generated_1 = require("./generated/runContract.generated");
|
|
11
|
+
Object.defineProperty(exports, "IDEMPOTENCY_KEY_MAX_LENGTH", { enumerable: true, get: function () { return runContract_generated_1.IDEMPOTENCY_KEY_MAX_LENGTH; } });
|
|
12
|
+
Object.defineProperty(exports, "QUOTE_HASH_PATTERN", { enumerable: true, get: function () { return runContract_generated_1.QUOTE_HASH_PATTERN; } });
|
|
13
|
+
Object.defineProperty(exports, "RUN_MODES", { enumerable: true, get: function () { return runContract_generated_1.RUN_MODES; } });
|
package/dist/runWait.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { DreamstateClient } from './client';
|
|
2
2
|
/** The wait ran out with the run still active; the latest run envelope is printed. */
|
|
3
3
|
export declare const RUN_WAIT_TIMEOUT_EXIT_CODE: number;
|
|
4
|
-
export declare function columnRunReturnsRunId(capabilityId: string): boolean;
|
|
5
4
|
export interface RunWaitResult {
|
|
6
5
|
value: unknown;
|
|
7
6
|
timedOut: boolean;
|
package/dist/runWait.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runWait.d.ts","sourceRoot":"","sources":["../src/runWait.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAQjD,sFAAsF;AACtF,eAAO,MAAM,0BAA0B,EAAE,MAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"runWait.d.ts","sourceRoot":"","sources":["../src/runWait.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAQjD,sFAAsF;AACtF,eAAO,MAAM,0BAA0B,EAAE,MAAyB,CAAC;AAEnE,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;CACnB;AA+BD,wBAAsB,UAAU,CAC9B,MAAM,EAAE,gBAAgB,EACxB,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,MAAM,EACtB,KAAK,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GAC7C,OAAO,CAAC,aAAa,CAAC,CAmBxB"}
|
package/dist/runWait.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RUN_WAIT_TIMEOUT_EXIT_CODE = void 0;
|
|
4
|
-
exports.columnRunReturnsRunId = columnRunReturnsRunId;
|
|
5
4
|
exports.waitForRun = waitForRun;
|
|
6
5
|
const errors_1 = require("./errors");
|
|
7
6
|
const TERMINAL_STATUSES = new Set([
|
|
@@ -10,18 +9,6 @@ const TERMINAL_STATUSES = new Set([
|
|
|
10
9
|
]);
|
|
11
10
|
/** The wait ran out with the run still active; the latest run envelope is printed. */
|
|
12
11
|
exports.RUN_WAIT_TIMEOUT_EXIT_CODE = errors_1.CLI_EXIT.TIMEOUT;
|
|
13
|
-
const COLUMN_RUN_HAND_OFF = new Set([
|
|
14
|
-
'tables.columns.run',
|
|
15
|
-
'tables.columns.run_all',
|
|
16
|
-
'tables.columns.run_remaining',
|
|
17
|
-
]);
|
|
18
|
-
// timing:async column runs. The tools response is the durable run id. Waiting
|
|
19
|
-
// folds every provider row into the command. Progress and final cells are
|
|
20
|
-
// runs_get and rows.query. Other mutations still wait so the next command can
|
|
21
|
-
// read steps[0].outputs.
|
|
22
|
-
function columnRunReturnsRunId(capabilityId) {
|
|
23
|
-
return COLUMN_RUN_HAND_OFF.has(capabilityId);
|
|
24
|
-
}
|
|
25
12
|
function runFromEnvelope(value) {
|
|
26
13
|
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
27
14
|
return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trydreamstate/cli",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.4",
|
|
4
4
|
"description": "Live command-line client for the Dreamstate v1 API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -19,13 +19,15 @@
|
|
|
19
19
|
"README.md"
|
|
20
20
|
],
|
|
21
21
|
"scripts": {
|
|
22
|
-
"build": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsc && node scripts/build-agent-plugin.mjs",
|
|
22
|
+
"build": "node scripts/generate-pack-verbs.mjs --check && node scripts/generate-run-contract.mjs --check && node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsc && node scripts/build-agent-plugin.mjs",
|
|
23
23
|
"test": "node scripts/build-agent-plugin.mjs --check && npm run build && jest --config jest.config.cjs --runInBand",
|
|
24
24
|
"type-check": "tsc --noEmit",
|
|
25
25
|
"pack:check": "npm pack --dry-run",
|
|
26
26
|
"pack:smoke": "npm run build && node scripts/pack-smoke.mjs",
|
|
27
27
|
"prepublishOnly": "npm run build && npm run type-check && npm test",
|
|
28
28
|
"verify:guidance": "node scripts/build-agent-plugin.mjs --check",
|
|
29
|
+
"verify:pack-verbs": "node scripts/generate-pack-verbs.mjs --check",
|
|
30
|
+
"verify:run-contract": "node scripts/generate-run-contract.mjs --check",
|
|
29
31
|
"verify:test-collection": "jest --config jest.config.cjs --runInBand --testNamePattern='^(?!)'",
|
|
30
32
|
"plugin:publish": "bash scripts/publish-plugin-repo.sh"
|
|
31
33
|
},
|