sim 2.2.32 → 2.2.33-preview.317.1

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 (36) hide show
  1. package/README.md +42 -0
  2. package/THIRD_PARTY_LICENSES +31 -0
  3. package/dist/auth/refresh.d.ts +2 -1
  4. package/dist/commands/protocol/files-get.d.ts +3 -0
  5. package/dist/commands/protocol/result.d.ts +7 -1
  6. package/dist/commands/protocol/source-dir.d.ts +263 -0
  7. package/dist/commands/protocol/source-exit-codes.d.ts +8 -0
  8. package/dist/commands/protocol/source-primer.d.ts +14 -0
  9. package/dist/commands/protocol/source-status.d.ts +154 -0
  10. package/dist/commands/protocol/source-tree.d.ts +159 -0
  11. package/dist/commands/protocol/source-ui.d.ts +89 -0
  12. package/dist/commands/protocol/stored-edges.d.ts +44 -0
  13. package/dist/commands/protocol/workflow-source-apply.d.ts +38 -0
  14. package/dist/commands/protocol/workflow-source-check.d.ts +70 -0
  15. package/dist/commands/protocol/workflow-source-get.d.ts +40 -0
  16. package/dist/commands/protocol/workflow-source-params.d.ts +7 -0
  17. package/dist/commands/protocol/workflow-source-status.d.ts +14 -0
  18. package/dist/commands/protocol/workspace-source-apply.d.ts +15 -0
  19. package/dist/commands/protocol/workspace-source-blobs.d.ts +111 -0
  20. package/dist/commands/protocol/workspace-source-check.d.ts +7 -0
  21. package/dist/commands/protocol/workspace-source-dir.d.ts +135 -0
  22. package/dist/commands/protocol/workspace-source-get.d.ts +13 -0
  23. package/dist/commands/protocol/workspace-source-status.d.ts +13 -0
  24. package/dist/contract/types.d.ts +5 -0
  25. package/dist/embed-context.d.ts +6 -3
  26. package/dist/exit-codes.d.ts +66 -0
  27. package/dist/generated/v2-api.d.ts +1297 -1
  28. package/dist/http/client.d.ts +22 -0
  29. package/dist/index.js +59130 -20427
  30. package/dist/output/io.d.ts +6 -0
  31. package/dist/program.d.ts +1 -1
  32. package/dist/runtime.js +59149 -20446
  33. package/dist/terminal/interrupts.d.ts +23 -0
  34. package/dist/terminal/line-input.d.ts +8 -0
  35. package/dist/terminal.d.ts +1 -0
  36. package/package.json +5 -1
@@ -0,0 +1,135 @@
1
+ import type { WorkflowInput } from '@sim/workflow-code';
2
+ import { type BlobEntry, type FlatDiagnostic, type WorkspaceDiagnosticCode, type WorkspaceKind } from '@sim/workspace-code';
3
+ import type { ApplyWorkspaceSourceBody } from '../../generated/v2-api';
4
+ import { type StatDigest, type Written } from './source-dir';
5
+ import { type LocalDeclarations, type SourceTreeProfile } from './source-tree';
6
+ /** The workspace directory's tree beside the printed source. */
7
+ export declare const WORKSPACE_TREE: SourceTreeProfile;
8
+ /**
9
+ * The keys a directory's files (path → text) declare, under the manifest list each kind's spec
10
+ * names: its tables (typed from their declarations), its knowledge base, skill, custom tool and
11
+ * workflow keys (grouped from their paths), and the secret names and credential keys its root
12
+ * files declare (read from their text; a file that does not read declares none, and is still
13
+ * typed live), with the modules those declarations live in. `workspace.d.ts` types them beside the
14
+ * stored resources.
15
+ */
16
+ export declare function localDeclarations(files: Readonly<Record<string, string>>): LocalDeclarations;
17
+ /** A table column as a workflow's row writes name it. */
18
+ interface DeclaredColumn {
19
+ /** The option names of a `select` column. */
20
+ options?: readonly string[];
21
+ /** A `select` column whose cells hold several options. */
22
+ multiple?: boolean;
23
+ }
24
+ /** What a workspace directory declares, for an offline compile of one of its workflows. */
25
+ export interface WorkspaceDeclarations {
26
+ /** The names `secrets.ts` declares; absent when the directory has no readable file. */
27
+ envNames?: ReadonlySet<string>;
28
+ /**
29
+ * The keys declared for each resource kind a workflow names them by (`table`, `credential`,
30
+ * …), for the kinds the directory manages (its folder or root file exists and reads): a get
31
+ * writes every resource of such a kind, so a key outside the list names nothing an apply can
32
+ * resolve.
33
+ */
34
+ keys: ReadonlyMap<string, ReadonlySet<string>>;
35
+ /** Each declared table's columns, by table key and then by stored column name. */
36
+ tables: ReadonlyMap<string, ReadonlyMap<string, DeclaredColumn>>;
37
+ /**
38
+ * What the declared rows of each table (`tables/<key>.rows.jsonl`) hold that an apply refuses,
39
+ * each at its line: a line that is not a JSON object of declared columns, a managed key two
40
+ * lines share, and a row the write refuses (`refusedTableRows`).
41
+ */
42
+ rowFindings: readonly RowFinding[];
43
+ /** What `workspace.d.ts` types from the directory's declarations (`localDeclarations`). */
44
+ local: LocalDeclarations;
45
+ /**
46
+ * Each workflow's inputs (`startInputs`: its Start trigger's fields, `null` without one), by
47
+ * key, for the workflows that compiled; set by a check, which compiles them.
48
+ */
49
+ workflowInputs?: ReadonlyMap<string, readonly WorkflowInput[] | null>;
50
+ }
51
+ /**
52
+ * A finding about a line of a table's rows file: `E_TABLE_ROWS`, an error, or the
53
+ * `I_FINDINGS_TRUNCATED` that ends a long list.
54
+ */
55
+ interface RowFinding {
56
+ code: WorkspaceDiagnosticCode;
57
+ severity: FlatDiagnostic['severity'];
58
+ message: string;
59
+ hint?: string;
60
+ file: string;
61
+ line: number;
62
+ column: number;
63
+ }
64
+ /**
65
+ * Reads what the workspace directory `root` declares: its secret names, the keys of each
66
+ * resource kind it manages, and its tables' columns. Only the root files and table files are read.
67
+ */
68
+ export declare function readWorkspaceDeclarations(root: string): Promise<WorkspaceDeclarations>;
69
+ /**
70
+ * The rows files of the tables `files` (a get's answer) declares seed rows for. A server read
71
+ * prints a seed table's `rows` but never its rows, which only the directory holds, so a get keeps
72
+ * the file it finds there.
73
+ */
74
+ export declare function seedRowsFiles(files: Readonly<Record<string, string>>): Set<string>;
75
+ /** Refuses a server answer naming a path outside every kind folder, before anything is written. */
76
+ export declare function assertWorkspacePaths(paths: Iterable<string>): void;
77
+ /**
78
+ * The folders (and root files) of `kinds`, each walked once: `present`, the kinds whose folder
79
+ * holds any file (its `.gitkeep` marker included) or whose root file exists; `paths`, their source
80
+ * files; and `ignored`, the rest (a hidden name, or a character no workspace path holds), which
81
+ * are never sent. The marker is neither.
82
+ */
83
+ export declare function kindFolders(dir: string, kinds: readonly WorkspaceKind[]): Promise<{
84
+ present: WorkspaceKind[];
85
+ paths: string[];
86
+ ignored: string[];
87
+ }>;
88
+ /**
89
+ * Refuses a directory a workspace command would find nothing in, so a mistyped `--dir` or a
90
+ * workflow folder fails instead of passing with nothing checked or applied.
91
+ */
92
+ export declare function assertWorkspaceDir(dir: string): Promise<void>;
93
+ /**
94
+ * A kind folder's marker, so an emptied folder keeps managing its kind; `null` for a kind one root
95
+ * file declares, which a get always writes.
96
+ */
97
+ export declare function keepFile(kind: WorkspaceKind): string | null;
98
+ /** What an apply sends, read from the directory. */
99
+ export interface WorkspaceSubmission {
100
+ kinds: WorkspaceKind[];
101
+ files: Record<string, string>;
102
+ blobs: BlobEntry[];
103
+ base?: ApplyWorkspaceSourceBody['base'];
104
+ /** Files under a kind folder that are not sent: hidden names and unsupported characters. */
105
+ ignored: string[];
106
+ /** The blobs this read hashed or reused a recorded digest for, with their stats. */
107
+ hashed: ReadonlyMap<string, StatDigest>;
108
+ }
109
+ /**
110
+ * `submission` (read `whole`) as a read without `whole` sends it: its unchanged workflow folders
111
+ * pruned for `workspaceId`, without walking, reading or hashing the directory again.
112
+ */
113
+ export declare function withUnchangedWorkflowsPruned(submission: WorkspaceSubmission, written: Written, workspaceId: string): WorkspaceSubmission;
114
+ /**
115
+ * Reads the directory for an apply to `workspaceId`. A workflow folder whose every file is as the
116
+ * CLI last wrote it is sent as `unchangedFiles` says (its base alone when it was read from
117
+ * `workspaceId`), so an apply sends only the workflows that were edited, and a copy to another
118
+ * workspace still sends every workflow it creates. `written` is `.sim/written.json` as the command
119
+ * read it. Blobs are hashed as streams (reusing the digest `written` records for one whose size and
120
+ * modification time are unchanged), and one over the size limit is refused (exit 7) before it is
121
+ * read, as is a directory listing more blobs than one holds, before any is: the server would
122
+ * refuse the apply only after every one was staged. `limits` are the server's
123
+ * (`WORKSPACE_SOURCE_LIMITS`) unless given. With `whole`, every workflow folder is sent with its
124
+ * files, as a status's dry run sends them so the server compares each with the stored workflow.
125
+ */
126
+ export declare function readWorkspaceDir(dir: string, only: readonly WorkspaceKind[] | undefined, workspaceId: string, written: Written, options?: {
127
+ whole?: boolean;
128
+ limits?: {
129
+ maxBlobs: number;
130
+ maxBlobBytes: number;
131
+ };
132
+ }): Promise<WorkspaceSubmission>;
133
+ /** `.sim/skipped.json`, or `null` when nothing was skipped. */
134
+ export declare function skippedFile(skipped: readonly unknown[]): string | null;
135
+ export {};
@@ -0,0 +1,13 @@
1
+ import { type WorkspaceKind } from '@sim/workspace-code';
2
+ import type { Command } from 'commander';
3
+ /** `--only`'s help: every kind by its folder. */
4
+ export declare const ONLY_KINDS_HELP: string;
5
+ /** `--only tables,workflows` (folders) or `--only table,workflow` (kinds) as kinds. */
6
+ export declare function parseKinds(value: string | undefined): WorkspaceKind[] | undefined;
7
+ /**
8
+ * `sim workspaces source get --dir <dir> [--only kinds]`: writes the workspace as a source
9
+ * directory: `tables/`, `tools/`, `skills/`, `knowledge/`, `files/` and `workflows/<key>/` (each a
10
+ * workflow source directory), the base, and the SDK declarations once at the root, so
11
+ * `workspaces source apply` can write it back.
12
+ */
13
+ export declare function attachWorkspaceSourceGet(source: Command): void;
@@ -0,0 +1,13 @@
1
+ import type { Command } from 'commander';
2
+ /**
3
+ * `sim workspaces source status [--dir <dir>]`: the local changes since the directory was read,
4
+ * and (unless `--offline`, or when the server cannot be reached) what a dry run says changed on
5
+ * the server since: drift, and conflicts where both sides changed. Ends with the next command.
6
+ */
7
+ export declare function attachWorkspaceSourceStatus(source: Command): void;
8
+ /**
9
+ * `sim workspaces source diff [paths...] [--dir <dir>] [--server]`: the content of each change.
10
+ * Without `--server`, each locally changed file against what the directory was read at; with it,
11
+ * every selected file against the server's current source.
12
+ */
13
+ export declare function attachWorkspaceSourceDiff(source: Command): void;
@@ -318,6 +318,11 @@ export interface CommandSpec {
318
318
  * the point is that the caller can tell whether they meant it.
319
319
  */
320
320
  confirm?: string;
321
+ /**
322
+ * Accept `-y/--yes` without a `confirm` gate, as a no-op: a write callers run beside confirmed
323
+ * ones (a deploy after `workflows source apply --yes`) takes the flag they pass there.
324
+ */
325
+ acceptsYes?: true;
321
326
  /**
322
327
  * Discover table columns from inside this nested field as well as from the
323
328
  * row's own scalars.
@@ -62,8 +62,11 @@ export interface EmbedContext {
62
62
  /** The embedded-vs-standalone seam for soft-fail codes: context when embedded, global otherwise. */
63
63
  export declare function setSoftExitCode(code: number): void;
64
64
  export declare const embedStore: AsyncLocalStorage<EmbedContext>;
65
- /** Thrown in place of process.exit inside an embedded run. */
66
- export declare class EmbeddedExit extends Error {
65
+ /**
66
+ * Thrown in place of `process.exit`: an embedded run returns its code to the host, and the
67
+ * terminal CLI exits with it once its output is written out.
68
+ */
69
+ export declare class CliExit extends Error {
67
70
  readonly code: number;
68
71
  constructor(code: number);
69
72
  }
@@ -75,5 +78,5 @@ export declare class EmbeddedExit extends Error {
75
78
  * keeps the installed CLI's behavior byte-identical.
76
79
  */
77
80
  export declare function embeddedProfile(): ResolvedProfile | null;
78
- /** Exits the terminal CLI without terminating an embedding host. */
81
+ /** Ends the command with `code`, without terminating an embedding host. */
79
82
  export declare function exitCli(code: number): never;
@@ -6,3 +6,69 @@
6
6
  * not a failed one; a script still branches on the non-zero status.
7
7
  */
8
8
  export declare const STILL_RUNNING_EXIT_CODE = 4;
9
+ /**
10
+ * A `workflows source apply` or `workspaces source apply` whose workflow or resources changed
11
+ * since the directory was read: `409` with `SOURCE_STALE`, or `E_APPLY_STALE` on a dry run. Read
12
+ * it again and reapply the edit. Source errors and any other `409` (such as `SOURCE_NAME_TAKEN`)
13
+ * exit 1.
14
+ */
15
+ export declare const SOURCE_STALE_EXIT_CODE = 5;
16
+ /**
17
+ * A `workflows source apply`/`create` or `workspaces source apply` refused because a workflow or
18
+ * its folder is locked (`E_APPLY_LOCKED`).
19
+ */
20
+ export declare const SOURCE_LOCKED_EXIT_CODE = 6;
21
+ /**
22
+ * Source over the size limits (`413`, or a size finding on a dry run): refused by `workflows
23
+ * source apply`/`create` or `workspaces source apply`, or too large for a `workflows source` or
24
+ * `workspaces source` get, status or diff to read.
25
+ */
26
+ export declare const SOURCE_TOO_LARGE_EXIT_CODE = 7;
27
+ /**
28
+ * `workspaces source apply` stopped part-way on a server failure (`E_APPLY_FAILED`): the changes
29
+ * before the failed one were written and saved back into the directory, the rest were not
30
+ * attempted. Applying again continues. A write refused part-way exits as that refusal instead.
31
+ */
32
+ export declare const SOURCE_PARTIAL_EXIT_CODE = 8;
33
+ /**
34
+ * A request the server still answered `429` (rate limited) after the CLI resent it as often as it
35
+ * will, or a write it does not resend. Nothing was done by the refused request: wait a minute and
36
+ * run the command again.
37
+ */
38
+ export declare const RATE_LIMITED_EXIT_CODE = 9;
39
+ /**
40
+ * Busy, retry. A `workspaces source apply` refused because another apply is writing the workspace
41
+ * (`409` with `SOURCE_BUSY`), or any `workspaces source` command refused because another one holds
42
+ * the same directory (`SOURCE_DIR_BUSY`): nothing of this one was read or written. Wait for the
43
+ * other to finish, then run it again; a write the other apply made to a resource this directory
44
+ * changes then exits 5.
45
+ */
46
+ export declare const SOURCE_BUSY_EXIT_CODE = 10;
47
+ /**
48
+ * A `workflows source status` or `workspaces source status` whose directory holds changes no apply
49
+ * has saved, while the server (when it answered) changed nothing the directory read: applying
50
+ * writes them.
51
+ */
52
+ export declare const SOURCE_LOCAL_CHANGES_EXIT_CODE = 11;
53
+ /**
54
+ * A `workflows source status` or `workspaces source status` that found the server changed since
55
+ * the directory was read: drift (a resource edited, added or deleted on the server that the
56
+ * directory leaves alone) or a conflict (one also changed locally, so applying it is refused as
57
+ * stale). Local changes may exist beside it.
58
+ */
59
+ export declare const SOURCE_DRIFT_EXIT_CODE = 12;
60
+ /**
61
+ * No usable login: the profile has no credential (`AUTH_REQUIRED`, "Not logged in"), its OAuth
62
+ * login expired and cannot be refreshed, or the server refused the credential (`401`). Nothing
63
+ * was sent or done: run `sim login`, then the same command again. Apart from exit 1 (the source
64
+ * has errors, or another failure), so a script can tell a login to fix from a source to fix.
65
+ */
66
+ export declare const AUTH_REQUIRED_EXIT_CODE = 13;
67
+ /**
68
+ * A `workflows source apply`/`create` or `workspaces source apply` run without `--yes` where no
69
+ * terminal can ask: it printed the plan a dry run found, with no errors, and wrote nothing. Run
70
+ * the same command with `--yes` to apply that plan.
71
+ */
72
+ export declare const SOURCE_PLANNED_EXIT_CODE = 14;
73
+ /** The error code of an {@link AUTH_REQUIRED_EXIT_CODE} refusal the CLI raises itself. */
74
+ export declare const AUTH_REQUIRED_CODE = "AUTH_REQUIRED";