@trydreamstate/cli 1.3.4 → 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.
Files changed (46) hide show
  1. package/agent-plugin/.claude-plugin/plugin.json +1 -1
  2. package/agent-plugin/.codex-plugin/plugin.json +1 -1
  3. package/agent-plugin/skills/crm/SKILL.md +1 -1
  4. package/agent-plugin/skills/diagnostics/SKILL.md +1 -1
  5. package/agent-plugin/skills/dreamstate/SKILL.md +1 -1
  6. package/agent-plugin/skills/first-win/SKILL.md +1 -1
  7. package/agent-plugin/skills/inbox-replies/SKILL.md +1 -1
  8. package/agent-plugin/skills/knowledge/SKILL.md +1 -1
  9. package/agent-plugin/skills/linkedin-posts/SKILL.md +1 -1
  10. package/agent-plugin/skills/linkedin-warm-signals/SKILL.md +2 -2
  11. package/agent-plugin/skills/list-building/SKILL.md +2 -2
  12. package/agent-plugin/skills/list-building/column-authoring.md +2 -1
  13. package/agent-plugin/skills/outreach/SKILL.md +2 -2
  14. package/agent-plugin/skills/plays/SKILL.md +1 -1
  15. package/agent-plugin/skills/reddit-posts/SKILL.md +1 -1
  16. package/agent-plugin/skills/skill-authoring/SKILL.md +1 -1
  17. package/agent-plugin/skills/social/SKILL.md +1 -1
  18. package/agent-plugin/skills/visibility/SKILL.md +1 -1
  19. package/agent-plugin/skills/workflows/SKILL.md +1 -1
  20. package/agent-plugin/skills/worksheet-tidy/SKILL.md +1 -1
  21. package/agent-plugin/skills/writing/SKILL.md +1 -1
  22. package/agent-plugin/skills/x-posts/SKILL.md +1 -1
  23. package/dist/client.d.ts +4 -0
  24. package/dist/client.d.ts.map +1 -1
  25. package/dist/client.js +41 -3
  26. package/dist/commands/shared.d.ts.map +1 -1
  27. package/dist/commands/shared.js +2 -1
  28. package/dist/config.d.ts +5 -1
  29. package/dist/config.d.ts.map +1 -1
  30. package/dist/config.js +12 -2
  31. package/dist/gatedRun.d.ts +2 -0
  32. package/dist/gatedRun.d.ts.map +1 -1
  33. package/dist/gatedRun.js +130 -9
  34. package/dist/generated/packVerbs.generated.json +1 -1
  35. package/dist/index.d.ts +6 -0
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +115 -31
  38. package/dist/money.d.ts +10 -0
  39. package/dist/money.d.ts.map +1 -0
  40. package/dist/money.js +75 -0
  41. package/dist/runWait.d.ts.map +1 -1
  42. package/dist/runWait.js +2 -0
  43. package/dist/turnCache.d.ts +3 -1
  44. package/dist/turnCache.d.ts.map +1 -1
  45. package/dist/turnCache.js +6 -2
  46. package/package.json +1 -1
package/dist/money.js ADDED
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ /**
3
+ * Customers see credits. Provider USD (a key that pairs usd with a cost word,
4
+ * a cogs key other than cogs_credits, or a provider_cost / provider_spend
5
+ * prefix) is dropped. Dollar amounts in our own sentences become "an amount".
6
+ * Customer maps are not entered: annual_revenue_usd and price_usd stay.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.isProviderCostKey = isProviderCostKey;
10
+ exports.scrubDollarText = scrubDollarText;
11
+ exports.scrubCliOutput = scrubCliOutput;
12
+ const PROVIDER_COST_WORDS = new Set([
13
+ 'provider', 'cost', 'spend', 'spent', 'worst', 'reserved', 'counted', 'settled', 'ledger',
14
+ 'snapshot', 'actual', 'platform', 'vendor', 'upstream', 'internal',
15
+ ]);
16
+ const MARGIN_CONTEXT = new Set(['provider', 'platform', 'cogs', 'vendor']);
17
+ const CUSTOMER_DATA_CONTAINERS = new Set([
18
+ 'values', 'cells', 'cell_values', 'row_values', 'field_values', 'record_values',
19
+ 'fields', 'custom_fields', 'attributes', 'payload', 'params',
20
+ ]);
21
+ const SCHEMA_KEYWORDS = new Set([
22
+ 'type', '$ref', 'anyOf', 'oneOf', 'allOf', 'enum', 'const', 'properties', 'items', 'description', 'not',
23
+ ]);
24
+ const DOLLAR_AMOUNT_TEXT = /(?:US\$|\$)\s?\d[\d,]*(?:\.\d+)?(?:\s?(?:USD|dollars?))?|\b\d[\d,]*(?:\.\d+)?\s?(?:USD|dollars?)\b|\bUSD\s?\d[\d,]*(?:\.\d+)?/gi;
25
+ function snake(key) {
26
+ return key.replace(/([a-z0-9])([A-Z])/g, '$1_$2').replace(/[-\s.]+/g, '_').toLowerCase();
27
+ }
28
+ function isPlainObject(value) {
29
+ return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
30
+ }
31
+ function isProviderCostKey(key) {
32
+ const normalized = snake(key);
33
+ const tokens = normalized.split('_');
34
+ if (tokens.includes('cogs') && !tokens.includes('credits'))
35
+ return true;
36
+ if (normalized.startsWith('provider_cost') || normalized.startsWith('provider_spend'))
37
+ return true;
38
+ if (tokens.includes('usd') && tokens.some((token) => PROVIDER_COST_WORDS.has(token)))
39
+ return true;
40
+ if (tokens.includes('margin') && tokens.some((token) => MARGIN_CONTEXT.has(token)))
41
+ return true;
42
+ return false;
43
+ }
44
+ function scrubDollarText(text) {
45
+ DOLLAR_AMOUNT_TEXT.lastIndex = 0;
46
+ return text.replace(DOLLAR_AMOUNT_TEXT, 'an amount').replace(/\s{2,}/g, ' ');
47
+ }
48
+ function looksLikeSchemaProperties(value) {
49
+ if (!isPlainObject(value))
50
+ return false;
51
+ const entries = Object.values(value);
52
+ return entries.length > 0 && entries.every((entry) => isPlainObject(entry) && Object.keys(entry).some((key) => SCHEMA_KEYWORDS.has(key)));
53
+ }
54
+ function isCustomerContainer(key, value) {
55
+ if (key === 'properties')
56
+ return !looksLikeSchemaProperties(value);
57
+ return CUSTOMER_DATA_CONTAINERS.has(snake(key)) && isPlainObject(value);
58
+ }
59
+ function scrubCliOutput(value, depth = 0) {
60
+ if (depth > 32)
61
+ return value;
62
+ if (typeof value === 'string')
63
+ return scrubDollarText(value);
64
+ if (Array.isArray(value))
65
+ return value.map((entry) => scrubCliOutput(entry, depth + 1));
66
+ if (!isPlainObject(value))
67
+ return value;
68
+ const output = {};
69
+ for (const [key, child] of Object.entries(value)) {
70
+ if (isProviderCostKey(key))
71
+ continue;
72
+ output[key] = isCustomerContainer(key, child) ? child : scrubCliOutput(child, depth + 1);
73
+ }
74
+ return output;
75
+ }
@@ -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;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"}
1
+ {"version":3,"file":"runWait.d.ts","sourceRoot":"","sources":["../src/runWait.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAUjD,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
@@ -6,6 +6,8 @@ const errors_1 = require("./errors");
6
6
  const TERMINAL_STATUSES = new Set([
7
7
  'succeeded', 'completed', 'completed_with_errors', 'failed', 'cancelled', 'canceled', 'partially_completed',
8
8
  'timed_out', 'rejected', 'awaiting_approval', 'awaiting_input', 'waiting', 'waiting_approval', 'approval_required',
9
+ // A rehearsal already finished. Polling it as if it were still running times the command out.
10
+ 'dry_run_rehearsed', 'smoke_test_passed',
9
11
  ]);
10
12
  /** The wait ran out with the run still active; the latest run envelope is printed. */
11
13
  exports.RUN_WAIT_TIMEOUT_EXIT_CODE = errors_1.CLI_EXIT.TIMEOUT;
@@ -1,8 +1,9 @@
1
1
  export declare const TURN_REUSE_MS: number;
2
- /** The quote a dry run returned, and the exact input it priced. */
2
+ /** The quote a dry run returned, and the exact input it priced. maximum_credits is absent on entries written before the field existed: treat that as unknown, not free. */
3
3
  export type CachedQuote = {
4
4
  quote_hash: string;
5
5
  fingerprint: string;
6
+ maximum_credits?: number | null;
6
7
  };
7
8
  type CacheWarning = (error: NodeJS.ErrnoException) => void;
8
9
  export declare function turnCachePath(credentialsPath: string): string;
@@ -14,6 +15,7 @@ export declare function reusableTurnToken(path: string, baseUrl: string, apiKey:
14
15
  export declare function reusableTurn(path: string, baseUrl: string, apiKey: string, capabilityId: string, fingerprint: string, now?: number, onWarning?: CacheWarning): Promise<{
15
16
  token: string;
16
17
  quote_hash: string | null;
18
+ maximum_credits: number | null;
17
19
  } | null>;
18
20
  export declare function rememberTurnToken(path: string, baseUrl: string, apiKey: string, capabilityId: string, token: string, now?: number, onWarning?: CacheWarning, quote?: CachedQuote): Promise<void>;
19
21
  export declare function forgetTurnToken(path: string, baseUrl: string, apiKey: string, capabilityId: string, onWarning?: CacheWarning): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"turnCache.d.ts","sourceRoot":"","sources":["../src/turnCache.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,aAAa,QAAa,CAAC;AAExC,mEAAmE;AACnE,MAAM,MAAM,WAAW,GAAG;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC;AAGtE,KAAK,YAAY,GAAG,CAAC,KAAK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AM,EAAE,SAAS,CAAC,EAAE,YAAY,GAC5F,OAAO,CAAC,IAAI,CAAC,CAMf"}
package/dist/turnCache.js CHANGED
@@ -62,9 +62,13 @@ async function reusableTurn(path, baseUrl, apiKey, capabilityId, fingerprint, no
62
62
  if (!entry || typeof entry.token !== 'string' || now - entry.at >= exports.TURN_REUSE_MS)
63
63
  return null;
64
64
  const quote = entry.quote && entry.quote.fingerprint === fingerprint && typeof entry.quote.quote_hash === 'string'
65
- ? entry.quote.quote_hash
65
+ ? entry.quote
66
66
  : null;
67
- return { token: entry.token, quote_hash: quote };
67
+ return {
68
+ token: entry.token,
69
+ quote_hash: quote ? quote.quote_hash : null,
70
+ maximum_credits: quote && typeof quote.maximum_credits === 'number' ? quote.maximum_credits : null,
71
+ };
68
72
  }
69
73
  async function rememberTurnToken(path, baseUrl, apiKey, capabilityId, token, now = Date.now(), onWarning, quote) {
70
74
  const entries = await load(path, onWarning);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trydreamstate/cli",
3
- "version": "1.3.4",
3
+ "version": "1.3.5",
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",