@promigence/sdk 0.1.0-beta.12

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 (104) hide show
  1. package/NOTICE +14 -0
  2. package/README.md +54 -0
  3. package/dist/blake3.d.ts +10 -0
  4. package/dist/blake3.js +111 -0
  5. package/dist/bundle.d.ts +96 -0
  6. package/dist/bundle.js +227 -0
  7. package/dist/ca-guard.d.ts +1 -0
  8. package/dist/ca-guard.js +166 -0
  9. package/dist/caller.d.ts +73 -0
  10. package/dist/caller.js +47 -0
  11. package/dist/cjs/blake3.d.ts +10 -0
  12. package/dist/cjs/blake3.js +116 -0
  13. package/dist/cjs/bundle.d.ts +96 -0
  14. package/dist/cjs/bundle.js +242 -0
  15. package/dist/cjs/ca-guard.d.ts +1 -0
  16. package/dist/cjs/ca-guard.js +174 -0
  17. package/dist/cjs/caller.d.ts +73 -0
  18. package/dist/cjs/caller.js +57 -0
  19. package/dist/cjs/client.d.ts +3015 -0
  20. package/dist/cjs/client.js +2617 -0
  21. package/dist/cjs/command-errors.d.ts +41 -0
  22. package/dist/cjs/command-errors.js +43 -0
  23. package/dist/cjs/context.d.ts +119 -0
  24. package/dist/cjs/context.js +598 -0
  25. package/dist/cjs/core.d.ts +285 -0
  26. package/dist/cjs/core.js +290 -0
  27. package/dist/cjs/credstore.d.ts +90 -0
  28. package/dist/cjs/credstore.js +219 -0
  29. package/dist/cjs/dispatcher.d.ts +58 -0
  30. package/dist/cjs/dispatcher.js +91 -0
  31. package/dist/cjs/github.d.ts +158 -0
  32. package/dist/cjs/github.js +84 -0
  33. package/dist/cjs/gitlab.d.ts +104 -0
  34. package/dist/cjs/gitlab.js +24 -0
  35. package/dist/cjs/handles.d.ts +82 -0
  36. package/dist/cjs/handles.js +139 -0
  37. package/dist/cjs/hint.d.ts +1 -0
  38. package/dist/cjs/hint.js +10 -0
  39. package/dist/cjs/http2.d.ts +206 -0
  40. package/dist/cjs/http2.js +1932 -0
  41. package/dist/cjs/index.d.ts +34 -0
  42. package/dist/cjs/index.js +31 -0
  43. package/dist/cjs/keyed.gen.d.ts +1 -0
  44. package/dist/cjs/keyed.gen.js +10 -0
  45. package/dist/cjs/models.gen.d.ts +6162 -0
  46. package/dist/cjs/models.gen.js +2 -0
  47. package/dist/cjs/package.json +1 -0
  48. package/dist/cjs/proxy.d.ts +40 -0
  49. package/dist/cjs/proxy.js +257 -0
  50. package/dist/cjs/pty.d.ts +171 -0
  51. package/dist/cjs/pty.js +504 -0
  52. package/dist/cjs/sandbox.d.ts +537 -0
  53. package/dist/cjs/sandbox.js +736 -0
  54. package/dist/cjs/ssh.d.ts +25 -0
  55. package/dist/cjs/ssh.js +117 -0
  56. package/dist/cjs/trace.d.ts +33 -0
  57. package/dist/cjs/trace.js +88 -0
  58. package/dist/cjs/transport-worker.d.ts +1 -0
  59. package/dist/cjs/transport-worker.js +468 -0
  60. package/dist/cjs/warm.d.ts +1 -0
  61. package/dist/cjs/warm.js +43 -0
  62. package/dist/client.d.ts +3015 -0
  63. package/dist/client.js +2583 -0
  64. package/dist/command-errors.d.ts +41 -0
  65. package/dist/command-errors.js +36 -0
  66. package/dist/context.d.ts +119 -0
  67. package/dist/context.js +588 -0
  68. package/dist/core.d.ts +285 -0
  69. package/dist/core.js +266 -0
  70. package/dist/credstore.d.ts +90 -0
  71. package/dist/credstore.js +206 -0
  72. package/dist/dispatcher.d.ts +58 -0
  73. package/dist/dispatcher.js +86 -0
  74. package/dist/github.d.ts +158 -0
  75. package/dist/github.js +78 -0
  76. package/dist/gitlab.d.ts +104 -0
  77. package/dist/gitlab.js +20 -0
  78. package/dist/handles.d.ts +82 -0
  79. package/dist/handles.js +135 -0
  80. package/dist/hint.d.ts +1 -0
  81. package/dist/hint.js +7 -0
  82. package/dist/http2.d.ts +206 -0
  83. package/dist/http2.js +1921 -0
  84. package/dist/index.d.ts +34 -0
  85. package/dist/index.js +15 -0
  86. package/dist/keyed.gen.d.ts +1 -0
  87. package/dist/keyed.gen.js +7 -0
  88. package/dist/models.gen.d.ts +6162 -0
  89. package/dist/models.gen.js +1 -0
  90. package/dist/proxy.d.ts +40 -0
  91. package/dist/proxy.js +249 -0
  92. package/dist/pty.d.ts +171 -0
  93. package/dist/pty.js +496 -0
  94. package/dist/sandbox.d.ts +537 -0
  95. package/dist/sandbox.js +725 -0
  96. package/dist/ssh.d.ts +25 -0
  97. package/dist/ssh.js +114 -0
  98. package/dist/trace.d.ts +33 -0
  99. package/dist/trace.js +80 -0
  100. package/dist/transport-worker.d.ts +1 -0
  101. package/dist/transport-worker.js +466 -0
  102. package/dist/warm.d.ts +1 -0
  103. package/dist/warm.js +40 -0
  104. package/package.json +54 -0
@@ -0,0 +1,41 @@
1
+ /**
2
+ * `CommandTimeoutError` — a command killed at its own `timeoutMs`.
3
+ *
4
+ * It is a `CommandExitError`, so a `catch (e) { if (e instanceof CommandExitError) … }` written
5
+ * against earlier releases still catches it, and `exitCode` is still the command's own (137, the
6
+ * SIGKILL at the deadline). What changes is what it says: `code` is `task_timeout`, the message
7
+ * names the bound, and `timedOut` is `true`. A command that exits 137 for any other reason (an
8
+ * out-of-memory kill, a `kill -9`) stays a plain `CommandExitError`.
9
+ */
10
+ import { CommandExitError, type CommandResult } from "./core.js";
11
+ /** `2000` → `"2 s"`, `1500` → `"1.5 s"`. */
12
+ export declare function secondsText(ms: number): string;
13
+ export declare class CommandTimeoutError extends CommandExitError {
14
+ /** Always `true`: the command ran past its own bound and was killed there. */
15
+ readonly timedOut: true;
16
+ /** The bound it ran into, in ms, when the SDK knows it. */
17
+ readonly timeoutMs: number | undefined;
18
+ readonly code: string;
19
+ readonly fix: string;
20
+ readonly guide: string;
21
+ constructor(result: CommandResult, timeoutMs: number | undefined);
22
+ }
23
+ /**
24
+ * Was this exec answer a command killed at its own timeout? The buffered and the streamed answer
25
+ * both say so (`timed_out`, `reason: "timeout"`).
26
+ */
27
+ export declare function answerTimedOut(r: {
28
+ timed_out?: unknown;
29
+ reason?: unknown;
30
+ } | undefined): boolean;
31
+ /**
32
+ * The same question about a background command's exit record, which carries no `timed_out` of its
33
+ * own: a SIGKILL with no exit code whose running time reached the bound it was started with — the
34
+ * rule the API itself applies to a foreground command. Without a known bound, never.
35
+ */
36
+ export declare function exitTimedOut(exit: {
37
+ exit_code?: number | null;
38
+ signal?: number | null;
39
+ wall_ms?: number;
40
+ timed_out?: unknown;
41
+ } | undefined, timeoutMs: number | undefined): boolean;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CommandTimeoutError = void 0;
4
+ exports.secondsText = secondsText;
5
+ exports.answerTimedOut = answerTimedOut;
6
+ exports.exitTimedOut = exitTimedOut;
7
+ const core_js_1 = require("./core.js");
8
+ const hint_js_1 = require("./hint.js");
9
+ function secondsText(ms) {
10
+ const s = ms / 1000;
11
+ return `${Number.isInteger(s) ? s : Number(s.toFixed(3))} s`;
12
+ }
13
+ class CommandTimeoutError extends core_js_1.CommandExitError {
14
+ timedOut = true;
15
+ timeoutMs;
16
+ code;
17
+ fix;
18
+ guide;
19
+ constructor(result, timeoutMs) {
20
+ super(result);
21
+ this.code = "task_timeout";
22
+ this.timeoutMs = timeoutMs;
23
+ this.message = timeoutMs === undefined
24
+ ? `command timed out (killed at its timeout, exit ${result.exitCode})`
25
+ : `command timed out after ${secondsText(timeoutMs)} (killed at its timeoutMs bound of ${timeoutMs} ms, exit ${result.exitCode})`;
26
+ this.fix = "Give it longer: commands.run(cmd, { timeoutMs }) (unset, the bound is the sandbox's timeout, else 15 minutes). " +
27
+ "Pass { throwOnExit: false } to receive the result instead of this error.";
28
+ this.guide = `promigence agent-guide --section errors --code ${(0, hint_js_1.hintArg)(this.code)}`;
29
+ }
30
+ }
31
+ exports.CommandTimeoutError = CommandTimeoutError;
32
+ function answerTimedOut(r) {
33
+ return r?.timed_out === true || r?.reason === "timeout";
34
+ }
35
+ function exitTimedOut(exit, timeoutMs) {
36
+ if (!exit)
37
+ return false;
38
+ if (exit.timed_out === true)
39
+ return true;
40
+ if (timeoutMs === undefined || typeof exit.wall_ms !== "number")
41
+ return false;
42
+ return (exit.exit_code === null || exit.exit_code === undefined) && exit.signal === 9 && exit.wall_ms + 1 >= timeoutMs;
43
+ }
@@ -0,0 +1,119 @@
1
+ /**
2
+ * A local directory as a Dockerfile build context: what `packContext` sends, decided before
3
+ * anything leaves this machine.
4
+ *
5
+ * - **`.dockerignore` is applied here, always**, with the rules `docker build` uses: Go glob syntax
6
+ * plus `**`, `!` to bring a path back, the last matching line wins, a matched directory takes
7
+ * everything under it, and paths are read from the context root. A file the `.dockerignore`
8
+ * excludes is never uploaded. `<Dockerfile>.dockerignore` beside the Dockerfile is read instead
9
+ * of the root `.dockerignore` when it exists, as `docker build` does. The Dockerfile and the
10
+ * ignore files themselves are always sent, whatever a pattern says.
11
+ * - **`.git` is never sent** unless the `.dockerignore` has the line `!.git`: git history can hold
12
+ * credentials long deleted from the tree.
13
+ * - **Without a `.dockerignore`**, `node_modules`, `__pycache__`, `.venv` and `.DS_Store` are left
14
+ * out too, and a note says so; with one, only what it lists is left out.
15
+ * - Empty directories and permission bits travel as they are on disk; a set-user-ID or
16
+ * set-group-ID bit is cleared, with a note.
17
+ * - Files that look like credentials (`.env`, private keys, cloud credentials, ...) are refused,
18
+ * by name, unless `allowSecrets` says otherwise. The check goes by file name: it is
19
+ * best-effort and cannot see what a file holds, so look over the list (`listContext`) before
20
+ * you send a directory.
21
+ * - Symbolic links travel as links, never as the file they point at.
22
+ */
23
+ /** The prefix a packed directory travels under in `dockerfile.context`. */
24
+ export declare const CONTEXT_TAR_PREFIX = "tar;base64,";
25
+ /** The largest context accepted, counted in file bytes after `.dockerignore`. */
26
+ export declare const CONTEXT_MAX_BYTES: number;
27
+ /**
28
+ * Names left out when the context has no `.dockerignore`. With one, the `.dockerignore` alone
29
+ * decides, except for `.git` (sent only when it says `!.git`).
30
+ */
31
+ export declare const CONTEXT_SKIP: Set<string>;
32
+ /** The patterns of one ignore file, compiled. */
33
+ export interface DockerIgnore {
34
+ /** The ignore file these came from (`.dockerignore` or `<Dockerfile>.dockerignore`). */
35
+ readonly file: string;
36
+ /** The patterns as the build holds them, in file order: cleaned, an exception keeping its `!`. */
37
+ readonly patterns: readonly string[];
38
+ /** Whether any line is a `!` exception. */
39
+ readonly exceptions: boolean;
40
+ /** Whether a line says `!.git`, which is what sends `.git`. */
41
+ readonly sendsGit: boolean;
42
+ /**
43
+ * Is `path` (relative to the context root, `/`-separated) left out? The last pattern that
44
+ * matches it, or one of the directories above it, decides.
45
+ */
46
+ ignored(path: string): boolean;
47
+ }
48
+ /**
49
+ * Read an ignore file the way `docker build` reads it: a UTF-8 BOM is dropped; a line starting
50
+ * with `#` is a comment; each line is trimmed; `!` starts an exception; each pattern is cleaned
51
+ * (`a//b/../c` is `a/c`) and a leading `/` is dropped. A line the build cannot read (a lone `!`,
52
+ * an unclosed `[`, a trailing `\`) makes the build refuse the whole file, so it is refused here,
53
+ * naming the line, before anything is sent.
54
+ */
55
+ export declare function parseDockerignore(text: string, file?: string): DockerIgnore;
56
+ /**
57
+ * A `.dockerignore`'s patterns as a predicate, or `undefined` for a file with no patterns. Refuses
58
+ * a file the build could not read. Kept for code written against 0.1; `parseDockerignore` is the
59
+ * full reader.
60
+ */
61
+ export declare function dockerignoreMatcher(text: string): {
62
+ ignored: (rel: string) => boolean;
63
+ exceptions: boolean;
64
+ } | undefined;
65
+ /**
66
+ * Does this path look like a credential (`.env`, a private key, cloud or registry credentials, a
67
+ * token file, ...)? By name only: best-effort, it cannot see what a file holds. Templates such as
68
+ * `.env.example` are not.
69
+ */
70
+ export declare function secretLike(path: string): boolean;
71
+ /** What a build context is packed from and sent with. */
72
+ export interface ContextOptions {
73
+ /**
74
+ * The Dockerfile's path inside the context, `/`-separated (default `Dockerfile`). It is always
75
+ * sent, and `<it>.dockerignore`, when present, is read instead of the root `.dockerignore`.
76
+ */
77
+ dockerfile?: string;
78
+ /** More paths inside the context to send whatever `.dockerignore` says. */
79
+ keep?: readonly string[];
80
+ /** Refuse a context whose files add up to more than this many bytes (default `CONTEXT_MAX_BYTES`). */
81
+ maxBytes?: number;
82
+ /**
83
+ * Send files that look like credentials. Default `false`: they are refused, by name, and
84
+ * nothing is sent.
85
+ */
86
+ allowSecrets?: boolean;
87
+ /** Called with each note: what was left out by default, or changed on the way. */
88
+ onNote?: (note: string) => void;
89
+ }
90
+ /** What a build context would hold, before anything is sent. */
91
+ export interface ContextListing {
92
+ /** Every path that would be sent, sorted; a directory's ends in `/`. */
93
+ paths: string[];
94
+ /** How many of them are files or links. */
95
+ files: number;
96
+ /** The files' bytes. */
97
+ bytes: number;
98
+ /** What was left out by default or changed on the way, one sentence each. */
99
+ notes: string[];
100
+ /** The paths that would be sent and look like credentials. */
101
+ secrets: string[];
102
+ /** The ignore file applied, or `null` when there is none. */
103
+ ignoreFile: string | null;
104
+ }
105
+ /**
106
+ * What `packContext(dir, opts)` would send, without sending or packing anything: every path, the
107
+ * notes, and the files that look like credentials. Refuses only what `packContext` cannot read
108
+ * (an ignore file the build would refuse).
109
+ */
110
+ export declare function listContext(dir: string, opts?: ContextOptions): ContextListing;
111
+ /**
112
+ * Pack a directory into the string `dockerfile.context` takes. What is sent is decided here (see
113
+ * the module notes): files the `.dockerignore` excludes, and `.git`, are never uploaded; files
114
+ * that look like credentials are refused unless `allowSecrets`; a context over `maxBytes` after
115
+ * `.dockerignore` is refused. The same tree packs to the same snapshot whichever SDK packs it.
116
+ */
117
+ export declare function packContext(dir: string, opts?: ContextOptions): string;
118
+ /** The Dockerfile's path as the context sees it, for `dockerfile.path`. */
119
+ export declare function contextRelative(contextDir: string, dockerfilePath: string): string;