@madewithremy/admin 0.1.57 → 0.1.58

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 (87) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +1 -1
  3. package/dist/client.d.ts +199 -0
  4. package/dist/config.d.ts +8 -0
  5. package/dist/ctx.d.ts +36 -0
  6. package/dist/errors.d.ts +68 -0
  7. package/dist/http.d.ts +68 -0
  8. package/dist/index.d.ts +7 -9442
  9. package/dist/index.js +6 -6
  10. package/dist/index.js.map +7 -1
  11. package/dist/ops/agent.d.ts +44 -0
  12. package/dist/ops/analytics.d.ts +285 -0
  13. package/dist/ops/apps.d.ts +33 -0
  14. package/dist/ops/crashes.d.ts +86 -0
  15. package/dist/ops/cron.d.ts +40 -0
  16. package/dist/ops/data.d.ts +68 -0
  17. package/dist/ops/dataSourceConnectors.d.ts +80 -0
  18. package/dist/ops/dataSourceEvals.d.ts +208 -0
  19. package/dist/ops/dataSourceJobs.d.ts +141 -0
  20. package/dist/ops/dataSourceMappers.d.ts +125 -0
  21. package/dist/ops/dataSources.d.ts +654 -0
  22. package/dist/ops/db.d.ts +81 -0
  23. package/dist/ops/diagnostics.d.ts +42 -0
  24. package/dist/ops/domains.d.ts +250 -0
  25. package/dist/ops/email.d.ts +305 -0
  26. package/dist/ops/events.d.ts +56 -0
  27. package/dist/ops/feedback.d.ts +24 -0
  28. package/dist/ops/files.d.ts +166 -0
  29. package/dist/ops/infra.d.ts +163 -0
  30. package/dist/ops/issues.d.ts +160 -0
  31. package/dist/ops/jewels.d.ts +249 -0
  32. package/dist/ops/methods.d.ts +60 -0
  33. package/dist/ops/prerender.d.ts +74 -0
  34. package/dist/ops/previews.d.ts +52 -0
  35. package/dist/ops/qaRecordings.d.ts +68 -0
  36. package/dist/ops/releases.d.ts +193 -0
  37. package/dist/ops/requests.d.ts +73 -0
  38. package/dist/ops/secrets.d.ts +69 -0
  39. package/dist/ops/settings.d.ts +45 -0
  40. package/dist/ops/tasks.d.ts +47 -0
  41. package/dist/ops/usage.d.ts +40 -0
  42. package/dist/ops/users.d.ts +59 -0
  43. package/dist/ops/voice.d.ts +178 -0
  44. package/dist/output.d.ts +19 -0
  45. package/dist/parseJsonConfig.d.ts +41 -0
  46. package/dist/poll.d.ts +38 -0
  47. package/dist/prod.js +21 -21
  48. package/dist/runningMethod.d.ts +25 -0
  49. package/dist/sleep.d.ts +12 -0
  50. package/dist/types/agent.d.ts +95 -0
  51. package/dist/types/analytics.d.ts +225 -0
  52. package/dist/types/apps.d.ts +39 -0
  53. package/dist/types/crashes.d.ts +81 -0
  54. package/dist/types/cron.d.ts +68 -0
  55. package/dist/types/data.d.ts +38 -0
  56. package/dist/types/dataSourceConnectors.d.ts +59 -0
  57. package/dist/types/dataSourceEvals.d.ts +225 -0
  58. package/dist/types/dataSourceJobs.d.ts +283 -0
  59. package/dist/types/dataSourceMappers.d.ts +204 -0
  60. package/dist/types/dataSourceReaders.d.ts +102 -0
  61. package/dist/types/dataSources.d.ts +627 -0
  62. package/dist/types/db.d.ts +63 -0
  63. package/dist/types/diagnostics.d.ts +96 -0
  64. package/dist/types/domains.d.ts +277 -0
  65. package/dist/types/email.d.ts +400 -0
  66. package/dist/types/events.d.ts +54 -0
  67. package/dist/types/feedback.d.ts +11 -0
  68. package/dist/types/files.d.ts +150 -0
  69. package/dist/types/index.d.ts +37 -0
  70. package/dist/types/infra.d.ts +188 -0
  71. package/dist/types/issues.d.ts +106 -0
  72. package/dist/types/jewels.d.ts +336 -0
  73. package/dist/types/methods.d.ts +34 -0
  74. package/dist/types/prerender.d.ts +59 -0
  75. package/dist/types/previews.d.ts +39 -0
  76. package/dist/types/progress.d.ts +31 -0
  77. package/dist/types/qaRecordings.d.ts +51 -0
  78. package/dist/types/releases.d.ts +233 -0
  79. package/dist/types/requests.d.ts +114 -0
  80. package/dist/types/secrets.d.ts +52 -0
  81. package/dist/types/settings.d.ts +79 -0
  82. package/dist/types/tasks.d.ts +99 -0
  83. package/dist/types/usage.d.ts +29 -0
  84. package/dist/types/users.d.ts +61 -0
  85. package/dist/types/voice.d.ts +197 -0
  86. package/dist/upload.d.ts +11 -0
  87. package/package.json +7 -10
@@ -0,0 +1,178 @@
1
+ /**
2
+ * Voice operations: phone numbers, sessions, and policy settings.
3
+ *
4
+ * `findNumberId` resolves a user-supplied E.164 string to a row id (list →
5
+ * normalize → match). It throws a plain Error with the exact historical
6
+ * message if not found — entry-point catch prints it identically to `fatal()`.
7
+ *
8
+ * Ops are pure: (ctx, params) → typed result, throwing AdminApiError /
9
+ * AdminTimeoutError. No printing, no process coupling.
10
+ */
11
+ import type { AdminContext } from '../ctx.js';
12
+ import type { VoiceNumbersListResult, VoiceNumbersSearchResult, VoiceNumbersBuyResult, VoiceNumbersReleaseResult, VoiceNumbersSetNameResult, VoiceSessionsListResult, VoiceSettingsGetResult, VoiceSettingsSetResult } from '../types/voice.js';
13
+ /**
14
+ * All dedicated phone numbers attached to the app.
15
+ *
16
+ * Lazily reconciles any pending orders so callers can poll this until a
17
+ * `pending` number converges to `active` or `failed`.
18
+ *
19
+ * @example
20
+ * const { numbers } = await admin.voice.numbersList();
21
+ * const active = numbers.filter((n) => n.status === 'active');
22
+ */
23
+ export declare function numbersList(ctx: AdminContext): Promise<VoiceNumbersListResult>;
24
+ export interface NumbersSearchParams {
25
+ /** US 3-digit area code to filter by. */
26
+ areaCode?: string;
27
+ /** City name to filter by. */
28
+ locality?: string;
29
+ /** State or region code (e.g. `CA`). */
30
+ administrativeArea?: string;
31
+ /** Max results to return (server clamps to 50). */
32
+ limit?: number;
33
+ }
34
+ /**
35
+ * Search available US numbers by area code or locality.
36
+ *
37
+ * Results are Telnyx availability snapshots — they are not reservations and
38
+ * may be gone by the time `numbersBuy` is called.
39
+ *
40
+ * @throws AdminApiError `missing_search_filter` (400) — neither areaCode nor
41
+ * locality provided; `invalid_area_code` (400) — area code is not 3 digits;
42
+ * `telnyx_not_configured` (412) — phone numbers are not available on this
43
+ * platform host.
44
+ * @example
45
+ * const { results } = await admin.voice.numbersSearch({ areaCode: '310', limit: 5 });
46
+ */
47
+ export declare function numbersSearch(ctx: AdminContext, params: NumbersSearchParams): Promise<VoiceNumbersSearchResult>;
48
+ export interface NumbersBuyParams {
49
+ /** E.164 US number to purchase, from a prior `numbersSearch` result. */
50
+ phoneNumber: string;
51
+ /** City name label — display metadata only, echoed from the search result. */
52
+ locality?: string;
53
+ /** State/region label — display metadata only, echoed from the search result. */
54
+ administrativeArea?: string;
55
+ /** Carrier monthly cost string (e.g. `"1.00000"`) — display metadata only. */
56
+ monthlyCost?: string;
57
+ }
58
+ /**
59
+ * Buy and attach a dedicated phone number to the app ($1/month billed to the
60
+ * workspace starting immediately — an agent acting for the user always
61
+ * confirms with them first).
62
+ *
63
+ * The number is an inbound line to the app's voice agent and a caller ID for
64
+ * `voice.call()`. An app can hold several, one per tenant say, up to its
65
+ * workspace's limit (10 unless support raised it), and the app's own methods
66
+ * can buy and release them with this client by declaring the `voice.manage`
67
+ * admin permission. A
68
+ * `pending` status usually activates within seconds; poll `numbersList` to
69
+ * confirm.
70
+ *
71
+ * @throws AdminApiError `invalid_phone_number` (400) — not a valid +1 E.164
72
+ * US number; `phone_number_limit_reached` (422) — the workspace holds as
73
+ * many numbers as it may; `number_unavailable` (412) — the number is no
74
+ * longer available; `insufficient_credits/*` (402) — the workspace can't
75
+ * cover it; `telnyx_not_configured` (412) — phone numbers unavailable on
76
+ * this host.
77
+ * @example
78
+ * const { number } = await admin.voice.numbersBuy({
79
+ * phoneNumber: '+13105551234',
80
+ * locality: 'Los Angeles',
81
+ * administrativeArea: 'CA',
82
+ * monthlyCost: '1.00000',
83
+ * });
84
+ */
85
+ export declare function numbersBuy(ctx: AdminContext, params: NumbersBuyParams): Promise<VoiceNumbersBuyResult>;
86
+ /**
87
+ * Release a dedicated phone number from the app (permanent).
88
+ *
89
+ * The monthly rental stops immediately (no refund for the current month),
90
+ * the carrier quarantines the number for ~15 days, and the number stops
91
+ * ringing the app and can't be a `voice.call()` caller ID. The app's other
92
+ * numbers are unaffected.
93
+ *
94
+ * @param e164 The phone number in E.164 or bare 10-digit US format.
95
+ * @throws Error `No phone number "${e164}" on this app` when not found;
96
+ * AdminApiError `number_not_found` (404) if the resolved id has gone stale;
97
+ * `order_in_progress` (412) — the purchase is still settling, try again in
98
+ * a minute.
99
+ * @example
100
+ * await admin.voice.numbersRelease('+13105551234');
101
+ */
102
+ export declare function numbersRelease(ctx: AdminContext, e164: string): Promise<VoiceNumbersReleaseResult>;
103
+ /**
104
+ * Set or clear the outbound caller-ID display name (CNAM) for a phone number.
105
+ *
106
+ * CNAM must be 1–15 letters, numbers, or spaces; carrier propagation takes
107
+ * 12–72 hours and display is ultimately the receiving carrier's call. Pass an
108
+ * empty string to remove the listing.
109
+ *
110
+ * @param e164 The phone number in E.164 or bare 10-digit US format.
111
+ * @param displayName 1–15 character CNAM string, or `""` to remove the listing.
112
+ * @throws Error `No phone number "${e164}" on this app` when not found;
113
+ * AdminApiError `number_not_found` (404) if the resolved id has gone stale;
114
+ * `number_not_active` (412) — the number must be active before setting a
115
+ * display name; `invalid_display_name` (400) — value is not 1–15 letters,
116
+ * numbers, or spaces.
117
+ * @example
118
+ * await admin.voice.numbersSetName('+13105551234', 'Acme Corp');
119
+ * // Clear the listing:
120
+ * await admin.voice.numbersSetName('+13105551234', '');
121
+ */
122
+ export declare function numbersSetName(ctx: AdminContext, e164: string, displayName: string): Promise<VoiceNumbersSetNameResult>;
123
+ export interface SessionsListParams {
124
+ /** Max sessions per page (default 20, server clamps to 100). */
125
+ limit?: number;
126
+ /** Pagination cursor from a prior page's `nextCursor`. */
127
+ cursor?: string;
128
+ }
129
+ /**
130
+ * Call log for the app (web, phone-out, phone-in sessions), newest first.
131
+ *
132
+ * Returns cursored pages; pass `nextCursor` from one page as `cursor` for the
133
+ * next. Transcripts are not included — fetch a session with `sessionsGet` for
134
+ * the full transcript.
135
+ *
136
+ * @example
137
+ * const { sessions, nextCursor } = await admin.voice.sessionsList({ limit: 20 });
138
+ */
139
+ export declare function sessionsList(ctx: AdminContext, params?: SessionsListParams): Promise<VoiceSessionsListResult>;
140
+ /**
141
+ * One voice session with full transcript and cost breakdown.
142
+ *
143
+ * `transcript` is the primary tool for debugging and iterating on a voice
144
+ * persona. `cost` is `null` while the session is still active.
145
+ *
146
+ * @throws AdminApiError `session_not_found` (404).
147
+ * @example
148
+ * const session = await admin.voice.sessionsGet('4f6c…');
149
+ * console.log(session.transcript);
150
+ */
151
+ export declare function sessionsGet(ctx: AdminContext, sessionId: string): Promise<import("../index.js").VoiceSessionDetail>;
152
+ /**
153
+ * Voice policy for the app: owner-set overrides, the effective (default-filled
154
+ * and ceiling-clamped) values that apply at session mint, and the platform
155
+ * ceilings.
156
+ *
157
+ * @example
158
+ * const { settings, effective, ceilings } = await admin.voice.settingsGet();
159
+ */
160
+ export declare function settingsGet(ctx: AdminContext): Promise<VoiceSettingsGetResult>;
161
+ export interface VoiceSettingsSetParams {
162
+ /** Cap on simultaneous sessions across all visitors (platform ceiling applies). */
163
+ maxConcurrentSessions?: number;
164
+ /** Cap on simultaneous sessions per visitor. */
165
+ maxConcurrentSessionsPerVisitor?: number;
166
+ /** Max session duration in seconds before the session is terminated. */
167
+ maxSessionDurationSecs?: number;
168
+ }
169
+ /**
170
+ * Override one or more voice-policy settings for the app (merge semantics —
171
+ * fields you omit keep their current values).
172
+ *
173
+ * @throws AdminApiError `invalid_voice_settings` (400) — a field value is not
174
+ * a positive number.
175
+ * @example
176
+ * await admin.voice.settingsSet({ maxConcurrentSessions: 5, maxSessionDurationSecs: 600 });
177
+ */
178
+ export declare function settingsSet(ctx: AdminContext, params: VoiceSettingsSetParams): Promise<VoiceSettingsSetResult>;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * The CLI's output contract, both halves in one place:
3
+ * results and errors go to stdout as JSON, human progress goes to stderr.
4
+ *
5
+ * That split is what lets a caller pipe stdout straight into a JSON parser
6
+ * while a person watching a long poll still sees something happen.
7
+ */
8
+ import type { OperationProgress } from './types/progress.js';
9
+ export declare function out(data: unknown): void;
10
+ /** Progress to stderr so stdout stays a clean stream of JSON values. */
11
+ export declare function progress(message: string): void;
12
+ /** "about 12 min left" or "about 2.5 h left"; null without an ETA. */
13
+ export declare function describeEta(eta: string | null, now?: number): string | null;
14
+ /**
15
+ * The one progress line every `--wait` prints: the operation's phase, its
16
+ * count, the platform's measured rate and ETA, and how long this wait has run.
17
+ * `extra` is the operation's own addendum (a job's spend, say).
18
+ */
19
+ export declare function renderProgress(p: OperationProgress, start?: number, extra?: string | null): string;
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Pure parser for MindStudio-owned JSON config files. No I/O, no repair.
3
+ *
4
+ * App configs (`mindstudio.json`, interface configs like `web.json`) are
5
+ * authored by remy, so they pick up the usual LLM-JSON slop — most often a
6
+ * trailing comma left behind when an array entry is deleted.
7
+ *
8
+ * Strategy: strict JSON.parse first, JSON5 as a rescue. Strict-first means the
9
+ * steady state is unaffected; the JSON5 path only engages for a file that would
10
+ * otherwise have failed outright.
11
+ *
12
+ * Deliberately pure and read-only: this short-lived CLI must not mutate the
13
+ * workspace out from under the running sandbox, whose own read path
14
+ * (`apps/agent/sandbox/src/utils/jsonConfig.ts`, where this module originated)
15
+ * repairs the file on disk for the callers that DO write.
16
+ */
17
+ export type ParseResult<T> = {
18
+ ok: true;
19
+ value: T;
20
+ repaired: false;
21
+ }
22
+ /** Strict parse failed; JSON5 rescued it. `error` is the strict failure. */
23
+ | {
24
+ ok: true;
25
+ value: T;
26
+ repaired: true;
27
+ error: string;
28
+ }
29
+ /** `notFound` separates "no such file" from "file exists but is broken" —
30
+ * callers log those very differently. */
31
+ | {
32
+ ok: false;
33
+ error: string;
34
+ notFound: boolean;
35
+ };
36
+ export declare function msg(err: unknown): string;
37
+ /**
38
+ * Parse a config string. Pure — no I/O, no repair. Use this when the caller
39
+ * already holds the file contents, or must not write (e.g. the CLI).
40
+ */
41
+ export declare function parseJsonConfig<T>(raw: string): ParseResult<T>;
package/dist/poll.d.ts ADDED
@@ -0,0 +1,38 @@
1
+ /**
2
+ * The one polling loop under every `--wait`: read the thing, ask whether it
3
+ * has settled, sleep, repeat, with a bounded grace for gateway errors and a
4
+ * timeout. The waits differ only in what they read, what "settled" means and
5
+ * how they describe progress; none of them owns a loop.
6
+ */
7
+ export interface PollOptions<T> {
8
+ /**
9
+ * How long the thing may go WITHOUT MOVING before the wait gives up. With
10
+ * `progressKey`, every change of the key restarts this clock, so an
11
+ * operation of any length is waited out as long as it keeps moving and the
12
+ * timeout bounds silence, not duration. Without it, the whole wait.
13
+ */
14
+ timeoutMs: number;
15
+ pollMs: number;
16
+ /** One line of progress for a value that has not settled; `start` is when the wait began. */
17
+ describe?: (value: T, start: number) => string;
18
+ /** Something that changes when the operation moves: a count, a phase, a timestamp. */
19
+ progressKey?: (value: T) => string | number | null | undefined;
20
+ onProgress?: (message: string) => void;
21
+ }
22
+ export type PollOutcome<T> = {
23
+ settled: true;
24
+ value: T;
25
+ } | {
26
+ settled: false;
27
+ value: T;
28
+ };
29
+ /**
30
+ * Poll `read` until `isSettled` says so or the timeout elapses. A wait can run
31
+ * for minutes through a tunnel; one gateway error is not an answer about the
32
+ * thing being waited on, so it is retried for `TRANSIENT_GRACE_MS` before it
33
+ * counts. Any other error propagates.
34
+ */
35
+ export declare function pollUntil<T>(read: () => Promise<T>, isSettled: (value: T) => boolean, options: PollOptions<T>): Promise<PollOutcome<T>>;
36
+ export declare function elapsedSeconds(start: number): number;
37
+ /** The standard timeout line: how long, and where the thing still is. */
38
+ export declare function timedOut(timeoutMs: number, still: string): string;
package/dist/prod.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/args.ts
4
- import { parseArgs } from "util";
4
+ import { parseArgs } from "node:util";
5
5
 
6
6
  // src/errors.ts
7
7
  var EXIT = {
@@ -1095,7 +1095,7 @@ Examples:
1095
1095
  remy-admin analytics crawlers recent`;
1096
1096
 
1097
1097
  // src/commands/releases.ts
1098
- import { execFileSync } from "child_process";
1098
+ import { execFileSync } from "node:child_process";
1099
1099
 
1100
1100
  // src/config.ts
1101
1101
  var WORKSPACE_DIR = process.env["WORKSPACE_DIR"] || "/home/remy/workspace";
@@ -2978,7 +2978,7 @@ Examples:
2978
2978
  remy-admin data lift-from-live --truncate --confirm`;
2979
2979
 
2980
2980
  // src/commands/issues.ts
2981
- import fs from "fs";
2981
+ import fs from "node:fs";
2982
2982
 
2983
2983
  // src/ops/issues.ts
2984
2984
  function authorship(ctx) {
@@ -3531,14 +3531,14 @@ Examples:
3531
3531
  remy-admin prerender get /demos/vector-search/blog/x --host example.com`;
3532
3532
 
3533
3533
  // src/commands/files.ts
3534
- import fs2 from "fs";
3535
- import path2 from "path";
3536
- import { Readable } from "stream";
3537
- import { pipeline } from "stream/promises";
3534
+ import fs2 from "node:fs";
3535
+ import path2 from "node:path";
3536
+ import { Readable } from "node:stream";
3537
+ import { pipeline } from "node:stream/promises";
3538
3538
 
3539
3539
  // src/ops/files.ts
3540
- import path from "path";
3541
- import { createHash } from "crypto";
3540
+ import path from "node:path";
3541
+ import { createHash } from "node:crypto";
3542
3542
 
3543
3543
  // src/upload.ts
3544
3544
  async function uploadDirect(upload, bytes, filename) {
@@ -3891,11 +3891,11 @@ Notes:
3891
3891
  - Public image URLs accept transform params, e.g. ?w=400&fit=cover.`;
3892
3892
 
3893
3893
  // src/commands/dataSources.ts
3894
- import fs6 from "fs";
3895
- import path6 from "path";
3894
+ import fs6 from "node:fs";
3895
+ import path6 from "node:path";
3896
3896
 
3897
3897
  // src/ops/dataSources.ts
3898
- import { createHash as createHash2 } from "crypto";
3898
+ import { createHash as createHash2 } from "node:crypto";
3899
3899
  var DEFAULT_WAIT_TIMEOUT_MS = 15 * 60 * 1e3;
3900
3900
  var POLL_MS2 = 3e3;
3901
3901
  function base(appId) {
@@ -4823,8 +4823,8 @@ Following an S3 bucket (connectors):
4823
4823
  `;
4824
4824
 
4825
4825
  // src/commands/dataSourceEvals.ts
4826
- import fs3 from "fs";
4827
- import path3 from "path";
4826
+ import fs3 from "node:fs";
4827
+ import path3 from "node:path";
4828
4828
 
4829
4829
  // src/ops/dataSourceEvals.ts
4830
4830
  var DEFAULT_WAIT_TIMEOUT_MS3 = 30 * 60 * 1e3;
@@ -5591,8 +5591,8 @@ Retrieval evals:
5591
5591
  `;
5592
5592
 
5593
5593
  // src/commands/dataSourceDictionary.ts
5594
- import fs4 from "fs";
5595
- import path4 from "path";
5594
+ import fs4 from "node:fs";
5595
+ import path4 from "node:path";
5596
5596
  var dataSourceDictionarySpecs = {
5597
5597
  "datasources dictionary push": {
5598
5598
  usage: "Usage: remy-admin datasources dictionary push [--source <slug>] [--linker-version <n>] <file.jsonl>",
@@ -5700,8 +5700,8 @@ Dictionary:
5700
5700
  `;
5701
5701
 
5702
5702
  // src/commands/dataSourceJobs.ts
5703
- import fs5 from "fs";
5704
- import path5 from "path";
5703
+ import fs5 from "node:fs";
5704
+ import path5 from "node:path";
5705
5705
  var dataSourceJobsSpecs = {
5706
5706
  "datasources jobs start": {
5707
5707
  usage: "Usage: remy-admin datasources jobs start [--source <slug>] (--store <name> [--access <private|public>] [--prefix <p>] | --manifest <file.jsonl>) [--limit <n>] [--budget <dollars>] [--concurrency <n>] [--priority] [--approve] [--wait] [--timeout <sec>]",
@@ -9390,7 +9390,7 @@ Examples:
9390
9390
  remy-admin cron run dailyDigest`;
9391
9391
 
9392
9392
  // src/commands/feedback.ts
9393
- import fs7 from "fs";
9393
+ import fs7 from "node:fs";
9394
9394
 
9395
9395
  // src/ops/feedback.ts
9396
9396
  function draft(ctx, message) {
@@ -10234,8 +10234,8 @@ var GROUP_HELP = {
10234
10234
  };
10235
10235
 
10236
10236
  // src/ctx.ts
10237
- import fs8 from "fs";
10238
- import path7 from "path";
10237
+ import fs8 from "node:fs";
10238
+ import path7 from "node:path";
10239
10239
 
10240
10240
  // src/parseJsonConfig.ts
10241
10241
  import JSON5 from "json5";
@@ -0,0 +1,25 @@
1
+ /**
2
+ * The context of an app method that is calling right now: its execution's own
3
+ * credential, so a method can manage its own app with no key in its secrets.
4
+ *
5
+ * The platform runs each method inside `@mindstudio-ai/agent`'s
6
+ * `runWithContext`, which carries the run's hook token and the api it calls
7
+ * back on. That token is accepted by the routes that manage the app when the
8
+ * method declares the admin permission the route needs (`adminPermissions` on
9
+ * the method's entry in `mindstudio.json`). The app id comes from the platform,
10
+ * asked once per token.
11
+ *
12
+ * The agent SDK is an optional peer, loaded here only when a client has no key
13
+ * of its own: it has to be the app's own copy, the one the runtime scoped the
14
+ * run with, and the CLI never needs it.
15
+ */
16
+ import { type AdminContext } from './ctx.js';
17
+ /**
18
+ * The context for a call made inside a running method, or null outside one.
19
+ * `appId` and `baseUrl` from the client's options override what the run says;
20
+ * an app id other than the run's own is refused by the platform.
21
+ */
22
+ export declare function runningMethodContext(options: {
23
+ appId?: string;
24
+ baseUrl?: string;
25
+ }): Promise<AdminContext | null>;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Do NOT unref() this timer, and do not "dedupe" it against the identically
3
+ * named helper in DraftSnapshotManager, which does.
4
+ *
5
+ * Inside the CLI's polling loops (`releases wait`, `releases status --wait`,
6
+ * `diagnostics get --wait`) this timer is often the only live handle, so an
7
+ * unref'd version lets node exit mid-wait: the poll silently abandons and never
8
+ * reports a result. Verified — the process exits 13 and the code after the
9
+ * sleep never runs. The server can unref safely because its sockets keep the
10
+ * loop alive; a short-lived CLI cannot.
11
+ */
12
+ export declare function sleep(ms: number): Promise<void>;
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Response types for the v2 agent-chat thread log.
3
+ *
4
+ * Transcribed from the api (apps/api/src/):
5
+ * roles/http/routes/Apps/manage/agentThreads.ts — routes
6
+ * customerApps/AppChatAgents/transcript.ts — transcript shape
7
+ * customerApps/AppChatAgents/dao/AgentThreadsDao.ts — list row shape
8
+ */
9
+ /** One tool the assistant asked for, with the arguments it chose. */
10
+ export interface AgentToolCall {
11
+ id: string;
12
+ name: string;
13
+ input: Record<string, unknown>;
14
+ }
15
+ /** A platform/model failure that ended a turn instead of a reply. */
16
+ export interface AgentTurnError {
17
+ message: string;
18
+ code?: string;
19
+ /** Milliseconds since epoch. */
20
+ at: number;
21
+ }
22
+ /**
23
+ * One message in a thread transcript.
24
+ *
25
+ * Roles are the stored conversation's own: `user` for a person's message AND
26
+ * for a tool result (which carries `toolCallId`), `assistant` for the agent.
27
+ */
28
+ export interface AgentTranscriptMessage {
29
+ role: string;
30
+ content: string;
31
+ /** CDN URLs the user attached (user messages only). */
32
+ attachments?: string[];
33
+ /** Present on an assistant message that requested tools. */
34
+ toolCalls?: AgentToolCall[];
35
+ /** Present on a tool result — matches the `toolCalls[].id` it answers. */
36
+ toolCallId?: string;
37
+ /** The tool reported a failure. */
38
+ isToolError?: boolean;
39
+ /**
40
+ * Request-log id for a method tool call — `requests get <id>` for its input,
41
+ * output, stdout and error. Absent on client-tool results, which run in the
42
+ * browser and never reach the backend.
43
+ */
44
+ requestId?: string;
45
+ /** The turn ended in a platform/model failure rather than a reply. */
46
+ turnError?: AgentTurnError;
47
+ /**
48
+ * The model saw extracted document text from an attachment on top of
49
+ * `content`. Only its presence is reported — the text can run to megabytes.
50
+ */
51
+ hasProcessedContent?: true;
52
+ }
53
+ /** One item in the thread list (transcript excluded). */
54
+ export interface AgentThreadListItem {
55
+ id: string;
56
+ /** Auto-generated from the first user message, or renamed by the user. */
57
+ title: string | null;
58
+ userId: string | null;
59
+ userName: string | null;
60
+ userEmail: string | null;
61
+ /** Browser identity — the only id an anonymous conversation has. */
62
+ visitorId: string | null;
63
+ /** True identifies a builder test conversation through the dev tunnel. */
64
+ devSession: boolean;
65
+ messageCount: number;
66
+ /** Tool results reported as failures — the conversations worth opening. */
67
+ toolErrorCount: number;
68
+ /** A turn broke (model error, rate limit, credits) rather than replying. */
69
+ hasTurnError: boolean;
70
+ /** ISO timestamp. */
71
+ dateCreated: string;
72
+ dateUpdated: string;
73
+ }
74
+ /** Full thread with transcript (single-thread GET). */
75
+ export interface AgentThreadDetail {
76
+ id: string;
77
+ title: string | null;
78
+ userId: string | null;
79
+ userName: string | null;
80
+ userEmail: string | null;
81
+ visitorId: string | null;
82
+ devSession: boolean;
83
+ messageCount: number;
84
+ /** ISO timestamp. */
85
+ dateCreated: string;
86
+ dateUpdated: string;
87
+ messages: AgentTranscriptMessage[];
88
+ }
89
+ /** GET /_internal/v2/apps/:appId/agent-threads */
90
+ export interface AgentThreadsListResult {
91
+ threads: AgentThreadListItem[];
92
+ nextCursor: string | null;
93
+ }
94
+ /** GET /_internal/v2/apps/:appId/agent-threads/:threadId */
95
+ export type AgentThreadsGetResult = AgentThreadDetail;