@uru-intelligence/cli 0.4.11 → 0.4.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.
- package/CHANGELOG.md +38 -0
- package/README.md +48 -3
- package/dist/library.mjs +84 -24
- package/dist/uru.mjs +3424 -544
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,24 +4,62 @@
|
|
|
4
4
|
|
|
5
5
|
## Unreleased
|
|
6
6
|
|
|
7
|
+
### Breaking
|
|
8
|
+
|
|
9
|
+
- gem.validate and gem.build return a hosted job id immediately. Pass --wait to poll gem.build_job until the compile settles. — surfaces: cli, docs; reference: skills/uru-gems/SKILL.md
|
|
10
|
+
- Action: Update agents and scripts that expected a compiler result from uru gems validate or uru gems build. Print or store hosted_job_id, then poll gem.build_job, or pass --wait.
|
|
11
|
+
|
|
7
12
|
### Security
|
|
8
13
|
|
|
9
14
|
- Bind npm publication to an attested candidate tarball and require the published cli_pin matrix before release success. — surfaces: cli, release; reference: docs/plans/cli-sdk-native-release-modernization/PLAN.md
|
|
10
15
|
- Action: Release operators must supply the exact candidate run, attempt, release-evidence artifact ID, and MCP commit to the protected publish workflow.
|
|
16
|
+
- Stop uru mcp config and install from printing or writing a live API token. Generated MCP config now points at the URU_API_KEY environment variable. — surfaces: cli; reference: apps/cli/src/local-commands.ts
|
|
17
|
+
- Action: Set URU_API_KEY in the MCP client environment. uru mcp config no longer embeds the current CLI token.
|
|
11
18
|
|
|
12
19
|
### Added
|
|
13
20
|
|
|
21
|
+
- Add `uru link --verify` for local link diagnostics and `uru gems links create --verify` to run browser verification after link creation. — surfaces: cli, docs; reference: apps/cli/src/workspace-commands.ts
|
|
22
|
+
- Action: Use `uru link --verify` to confirm `.uru/project.json` and the remote Gem still resolve before source work. After `uru gems links create`, add `--verify` to run `gem.browser_verify` on the new Link's Gem.
|
|
14
23
|
- Add a side-effect-free internal CLI library entrypoint with a typed whoami foundation. _(internal)_ — surfaces: cli, sdk; reference: docs/plans/cli-sdk-native-release-modernization/DECISION_RECORDS.md
|
|
15
24
|
- Action: Programmatic callers must pass an explicit token and workspace; no public SDK compatibility promise is introduced.
|
|
16
25
|
- Add direct CLI access to Home pins and Focus rules from the shared operation registry. — surfaces: cli, docs; reference: content/docs/home.mdx
|
|
17
26
|
- Action: Use uru home <operation> --params-json '{...}' or the matching home.* operation ID.
|
|
27
|
+
- Add first-class CLI verbs for Gem filesystem, deploy, build diagnostics, components, page verify, public-tool delegations, and bindings. — surfaces: cli, docs; reference: docs/reference/uru-cli-mcp-operations.md
|
|
28
|
+
- Action: Use uru gems fs, uru gems deploy, uru gems build logs|inspect, uru gems verify, uru gems components, uru gems delegations, and uru gems bindings. These wrap existing gem.* operations.
|
|
29
|
+
- Add first-class Dataset list/history/jobs/inspect verbs and a uru distribution group for the 17 collection operations. — surfaces: cli, docs; reference: content/docs/guides/cli.mdx
|
|
30
|
+
- Action: Use uru datasets ls|inspect|history|jobs and uru distribution list|get|create|update. Dataset SQL stays uru datasets sql. DATA-008 export/typegen is not added.
|
|
31
|
+
- Add first-class Library upload, patch-preview, and favorite verbs, plus automations validate, delete, graph-patch, triggers, connections, and update. — surfaces: cli, docs; reference: docs/reference/uru-cli-mcp-operations.md
|
|
32
|
+
- Action: Use uru library upload|patch-preview|favorite and uru automations validate|delete|graph-patch|triggers|connections|update instead of operations run for those catalog ids. library write --create now accepts --folder-id.
|
|
33
|
+
- Add first-class uru gems bindings and uru gems api commands so tool-call source and connection bindings stay separate. — surfaces: cli; reference: apps/cli/src/gem-lifecycle-resource-commands.ts
|
|
34
|
+
- Action: Use uru gems bindings list|upsert|resolve to attach connections, and uru gems api describe|query|action|job to run declared Gem capabilities. Do not put connection ids in Gem source.
|
|
35
|
+
- Add MCP list/target commands, auth status, text-mode list tables, and regenerate the full CLI/MCP operations reference. — surfaces: cli, docs; reference: docs/reference/uru-cli-mcp-operations.md
|
|
36
|
+
- Action: Use uru mcp list, uru auth status, and uru docs search. List commands print tables in text mode; --json stays JSON. Prefer ${URU_API_KEY} in generated MCP config.
|
|
37
|
+
- Add TTY visual chrome for help, tables, doctor, and login without changing JSON or pipe output. — surfaces: cli; reference: apps/cli/src/visual.ts
|
|
38
|
+
- Action: No action is required. Color and box drawing appear only on a color TTY. Use --no-color, CI, or a pipe to keep the previous plain text.
|
|
39
|
+
- Add uru tools inspect and uru operations inspect, and accept --params-json @file or @- for large tool parameters. — surfaces: cli; reference: apps/cli/src/command-spec.ts
|
|
40
|
+
- Action: Use uru tools inspect <name> or uru operations inspect <operation-id> to print a contract. Pass --params-json @path.json or --params-json @- to load parameters from a file or stdin.
|
|
41
|
+
- Make uru update compare this CLI to the latest npm version and add --check --json. — surfaces: cli; reference: apps/cli/src/update-check.ts
|
|
42
|
+
- Action: No action is required. uru update never installs itself. Run uru update --check --json for machine output, or npm install -g @uru-intelligence/cli@latest to install.
|
|
43
|
+
|
|
44
|
+
### Changed
|
|
45
|
+
|
|
46
|
+
- `uru logs --follow` streams Gem runtime logs over SSE for up to 30 minutes and falls back to polling when the stream route is missing. — surfaces: cli; reference: apps/cli/src/gem-lifecycle-commands.ts
|
|
47
|
+
- Action: No action is required. `--follow-duration-ms` now accepts up to 30 minutes (was 5).
|
|
18
48
|
|
|
19
49
|
### Fixed
|
|
20
50
|
|
|
51
|
+
- JSON output for destructive CLI operations refused without `--yes` now includes `confirmationRequired: true` and a copy-paste `suggestedCommand` with `--yes` appended. — surfaces: cli; reference: apps/cli/src/cli-runtime.ts
|
|
52
|
+
- Action: No action is required. Agents and scripts can read `suggestedCommand` from JSON errors instead of guessing the confirmation flag.
|
|
53
|
+
- Keep the CLI login when you switch workspace. A leftover workspace from a previous switch no longer poisons the next login. `uru switch` marks the current workspace in the list. — surfaces: cli; reference: apps/cli/src/oauth-credential.ts
|
|
54
|
+
- Action: No action is required. After you switch workspace, the next command keeps the same login. A new login writes only the workspace the login response selected.
|
|
55
|
+
- Recover from a revoked CLI session without reusing the dead JWT. When the API returns `session_revoked`, the CLI now rotates the stored OAuth login once or clears it instead of sending the revoked token until local expiry. — surfaces: cli; reference: apps/cli/src/cli.ts
|
|
56
|
+
- Action: No action is required. Failures of this class now carry the `session_revoked` error code so they can be distinguished from a generic `auth_required` response.
|
|
21
57
|
- Report a non-JSON API response as what it is. A proxy or firewall that answers with an HTML page now produces the HTTP status and content type instead of `Unexpected token '<', "<!DOCTYPE "... is not valid JSON`. — surfaces: cli; reference: apps/cli/src/client.ts
|
|
22
58
|
- Action: No action is required. Failures of this class now carry the `non_json_response` error code, keep the auth exit code on a 401, and print a tip naming the likely cause.
|
|
23
59
|
- Report what a rejected credential actually means: `uru doctor` now runs a read-only data call instead of trusting `uru whoami`, API error envelopes are read in full, and auth advice follows where the token came from. — surfaces: cli; reference: apps/cli/src/doctor.ts
|
|
24
60
|
- Action: No action is required. `uru doctor` gains a `data access` check and fails when a credential validates but cannot execute tools; a token supplied through `--token` or `URU_TOKEN` is no longer told to run `uru login`.
|
|
61
|
+
- Send scope on uru automations create, honor --output/--json on uru tools run, and keep errorId plus httpStatus on JSON errors. — surfaces: cli; reference: apps/cli/src/local-commands.ts
|
|
62
|
+
- Action: uru automations create now sends scope=workspace by default. Pass --scope personal when creating a personal automation. JSON errors include errorId and httpStatus when the API provides them.
|
|
25
63
|
- Use the shared SemVer contract when deciding whether to show a CLI update notice. — surfaces: cli, release; reference: docs/plans/cli-sdk-native-release-modernization/PLAN.md
|
|
26
64
|
- Action: No action is required; prerelease and malformed registry versions now follow the same validation and ordering rules as release publication.
|
|
27
65
|
|
package/README.md
CHANGED
|
@@ -61,24 +61,41 @@ bun src/index.ts library search revenue
|
|
|
61
61
|
bun src/index.ts library mkdir 'library/Golden Gems'
|
|
62
62
|
bun src/index.ts library read 'library/Contexts/Client Brief.md'
|
|
63
63
|
bun src/index.ts library write 'library/Contexts/Client Brief.md' --file ./brief.md --create
|
|
64
|
-
bun src/index.ts library write 'library/Prompts/Sales Email.md' --content "Draft the follow-up." --create
|
|
64
|
+
bun src/index.ts library write 'library/Prompts/Sales Email.md' --content "Draft the follow-up." --create --folder-id <folder-id>
|
|
65
|
+
bun src/index.ts library patch-preview 'library/Prompts/Sales Email.md' --content "*** Begin Patch\n..."
|
|
66
|
+
bun src/index.ts library favorite 'library/Contexts/Client Brief.md'
|
|
67
|
+
bun src/index.ts library upload 'library/Assets/logo.png' --file ./logo.png
|
|
68
|
+
bun src/index.ts library upload complete --upload-id <id> --bucket <bucket> --object-path <path> --filename logo.png --size-bytes 1024
|
|
65
69
|
bun src/index.ts library patch 'library/Prompts/Sales Email.md' --stdin
|
|
66
70
|
bun src/index.ts library cp 'library/Notes/Brief.md' 'library/Archive/Brief.md'
|
|
67
71
|
bun src/index.ts library mv 'library/Notes/Draft.md' 'library/Notes/Final.md'
|
|
68
72
|
bun src/index.ts library rm 'library/Notes/Old.md'
|
|
69
73
|
bun src/index.ts library restore 'library/Notes/Old.md'
|
|
74
|
+
bun src/index.ts datasets ls --limit 50 --json
|
|
70
75
|
bun src/index.ts datasets query revenue_rows --limit 50 --response-format concise --json
|
|
71
76
|
# Registry-family commands accept canonical camelCase fields and adapt them at
|
|
72
77
|
# the tool-protocol boundary.
|
|
73
78
|
bun src/index.ts datasets get revenue-rows
|
|
79
|
+
bun src/index.ts datasets history revenue-rows --limit 20
|
|
80
|
+
bun src/index.ts datasets jobs revenue-rows --limit 20
|
|
74
81
|
bun src/index.ts datasets rows --params-json '{"op":"upsert","datasetId":"revenue-rows","rows":[{"name":"Acme"}]}'
|
|
75
82
|
bun src/index.ts datasets create --params-json '{"title":"Revenue Rows","properties":[{"clientKey":"name","name":"Name","type":"title","required":true,"nullable":false,"position":0,"config":{}}]}'
|
|
83
|
+
bun src/index.ts datasets sql --params-json '{"sql":"SELECT 1"}'
|
|
84
|
+
bun src/index.ts distribution list --limit 20
|
|
85
|
+
bun src/index.ts distribution get <collection-id>
|
|
86
|
+
bun src/index.ts distribution create "Client pack" --scope workspace
|
|
76
87
|
|
|
77
88
|
# Automation helpers over the platform tool surface.
|
|
78
89
|
bun src/index.ts automations ls --limit 100
|
|
79
90
|
bun src/index.ts automations get <automation-id>
|
|
80
91
|
bun src/index.ts automations create "Daily revenue digest" --status draft
|
|
92
|
+
bun src/index.ts automations update <automation-id> --description "Nightly digest"
|
|
81
93
|
bun src/index.ts automations enable <automation-id>
|
|
94
|
+
bun src/index.ts automations validate <automation-id> --mode structural --graph-json '{}'
|
|
95
|
+
bun src/index.ts automations graph-patch <automation-id> --patch-json '{"ops":[]}'
|
|
96
|
+
bun src/index.ts automations triggers list <automation-id>
|
|
97
|
+
bun src/index.ts automations connections list
|
|
98
|
+
bun src/index.ts automations delete <automation-id> --yes
|
|
82
99
|
bun src/index.ts automations trigger <automation-id> --input-message "Run now"
|
|
83
100
|
bun src/index.ts automations runs ls <automation-id> --scope workspace --limit 20
|
|
84
101
|
bun src/index.ts automations runs tail <run-id> --level warn
|
|
@@ -95,11 +112,21 @@ bun src/index.ts operations ls --family automations
|
|
|
95
112
|
bun src/index.ts operations run gem.inspect --params-json '{"path":"library/Golden Gems/My Gem.gem"}'
|
|
96
113
|
bun src/index.ts library search "client brief"
|
|
97
114
|
bun src/index.ts docs library_fs
|
|
115
|
+
bun src/index.ts docs search library_fs
|
|
98
116
|
bun src/index.ts api platform/tools/search_tools/execute -F query=gem
|
|
117
|
+
bun src/index.ts api /api/platform/tools/search_tools/execute -F query=gem
|
|
99
118
|
|
|
100
|
-
# MCP client config helper. Prefer
|
|
119
|
+
# MCP client config helper. Prefer ${URU_API_KEY} or --api-key. List never prints keys.
|
|
120
|
+
bun src/index.ts mcp list
|
|
121
|
+
bun src/index.ts mcp list --target cursor
|
|
101
122
|
bun src/index.ts mcp config --api-key "$URU_API_KEY"
|
|
123
|
+
bun src/index.ts mcp install --target cursor
|
|
102
124
|
bun src/index.ts mcp install --path ~/.config/claude-code/mcp.json --api-key "$URU_API_KEY"
|
|
125
|
+
bun src/index.ts mcp remove --target cursor
|
|
126
|
+
|
|
127
|
+
# Local auth facts. Never prints a JWT.
|
|
128
|
+
bun src/index.ts auth status --json
|
|
129
|
+
bun src/index.ts doctor --json
|
|
103
130
|
|
|
104
131
|
# Local shell integration.
|
|
105
132
|
bun src/index.ts complete bash
|
|
@@ -141,7 +168,7 @@ explicit token/API-key paths:
|
|
|
141
168
|
- `uru login --token ...` stores the token in OS credential storage when available: macOS Keychain, Linux `secret-tool`/libsecret, or Windows Credential Manager via PowerShell
|
|
142
169
|
- `uru login --token ... --insecure-storage` is the explicit plaintext fallback
|
|
143
170
|
- Linux token storage requires `secret-tool` (often installed as `libsecret-tools`); Windows token storage requires PowerShell access to Credential Manager. If the OS store is unavailable, login fails closed with an actionable `--insecure-storage` fallback message.
|
|
144
|
-
- browser/device credentials renew within five minutes of session expiry and
|
|
171
|
+
- browser/device credentials renew within five minutes of session expiry. A workspace switch is request scope and does not rotate the login.
|
|
145
172
|
- interactive commands with missing or expired stored auth start browser login and then retry the command without printing login success text to stdout
|
|
146
173
|
- `--no-input` disables implicit login and exits `4` when authentication is missing
|
|
147
174
|
- `uru logout` invalidates the current CLI session, revokes the renewable OAuth credential, and clears local auth state
|
|
@@ -151,6 +178,9 @@ explicit token/API-key paths:
|
|
|
151
178
|
- config file permissions: `0600`
|
|
152
179
|
- linked project state: `.uru/project.json` with `{workspaceId, gemId, libraryPath}`
|
|
153
180
|
- no credentials are written to `.uru/project.json`
|
|
181
|
+
- `uru auth status` reports logged-in / workspace / storage / expiry and never prints a JWT. `uru whoami` stays a server identity call.
|
|
182
|
+
- `uru switch` sets the local default workspace. `uru link` binds this directory to one Gem. `--workspace` / `URU_WORKSPACE_ID` override one invocation.
|
|
183
|
+
- The screen says Agent; Library paths and schemas say persona (`library/Agents/Name.persona.md`).
|
|
154
184
|
- Gem-scoped deploy tokens for CI use `uru tokens create|ls|revoke`
|
|
155
185
|
- `uru tokens create` requires `--name` plus exactly one lifetime flag:
|
|
156
186
|
`--expiry <duration>` or `--expires-at <iso timestamp>`
|
|
@@ -163,6 +193,21 @@ explicit token/API-key paths:
|
|
|
163
193
|
file
|
|
164
194
|
- `uru env run -- <cmd>` overlays local values and redacts all non-empty values from captured output
|
|
165
195
|
|
|
196
|
+
## CI cookbook
|
|
197
|
+
|
|
198
|
+
Use a Gem-scoped token, never a session JWT, and fail closed:
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
uru tokens create 'library/Golden Gems/My Gem.gem' --name CI --expiry 30d --json
|
|
202
|
+
export URU_TOKEN=<token-from-create-once>
|
|
203
|
+
export URU_WORKSPACE_ID=<workspace-id>
|
|
204
|
+
uru --no-input doctor --json
|
|
205
|
+
uru --no-input auth status --json
|
|
206
|
+
uru --no-input whoami --json
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
`--no-input` exits instead of opening a browser. `auth status` and `doctor` warn if the token lives in `--insecure-storage` and do not print the token. `env pull` writes names only; it does not download secret values.
|
|
210
|
+
|
|
166
211
|
## Install shape
|
|
167
212
|
|
|
168
213
|
The package name is `@uru-intelligence/cli`; the installed binary is still `uru`:
|
package/dist/library.mjs
CHANGED
|
@@ -6595,10 +6595,6 @@ var zArtifactToolPolicyReceiptTerminalResponse = union([
|
|
|
6595
6595
|
terminalized: literal(false)
|
|
6596
6596
|
})
|
|
6597
6597
|
]);
|
|
6598
|
-
var zAuditorConversationBootstrapRequest = object({
|
|
6599
|
-
evaluationId: string2().nullish(),
|
|
6600
|
-
forceNew: boolean2().optional().default(false)
|
|
6601
|
-
});
|
|
6602
6598
|
var zAuthMode = _enum(["oauth2", "bearer", "none"]).default("none");
|
|
6603
6599
|
var zAuthPreflightResponse = object({
|
|
6604
6600
|
expiresAt: exports_iso.datetime({ offset: true })
|
|
@@ -12931,21 +12927,6 @@ var zGetPrimaryRubricForAutomationApiAutomationsAutomationIdRubricGetQuery = obj
|
|
|
12931
12927
|
scope: _enum(["personal", "workspace"]).optional().default("personal")
|
|
12932
12928
|
});
|
|
12933
12929
|
var zGetPrimaryRubricForAutomationApiAutomationsAutomationIdRubricGetResponse = record(string2(), unknown());
|
|
12934
|
-
var zQuickCreateRubricForAutomationApiAutomationsAutomationIdRubricQuickCreatePostPath = object({
|
|
12935
|
-
automationId: string2()
|
|
12936
|
-
});
|
|
12937
|
-
var zQuickCreateRubricForAutomationApiAutomationsAutomationIdRubricQuickCreatePostQuery = object({
|
|
12938
|
-
scope: _enum(["personal", "workspace"]).optional().default("personal")
|
|
12939
|
-
});
|
|
12940
|
-
var zQuickCreateRubricForAutomationApiAutomationsAutomationIdRubricQuickCreatePostResponse = record(string2(), unknown());
|
|
12941
|
-
var zBootstrapRubricReviewConversationApiAutomationsAutomationIdRubricRubricIdConversationPostPath = object({
|
|
12942
|
-
automationId: string2(),
|
|
12943
|
-
rubricId: string2()
|
|
12944
|
-
});
|
|
12945
|
-
var zBootstrapRubricReviewConversationApiAutomationsAutomationIdRubricRubricIdConversationPostQuery = object({
|
|
12946
|
-
scope: _enum(["personal", "workspace"]).optional().default("personal")
|
|
12947
|
-
});
|
|
12948
|
-
var zBootstrapRubricReviewConversationApiAutomationsAutomationIdRubricRubricIdConversationPostResponse = record(string2(), unknown());
|
|
12949
12930
|
var zTriggerRubricEvaluationApiAutomationsAutomationIdRubricRubricIdEvaluatePostPath = object({
|
|
12950
12931
|
automationId: string2(),
|
|
12951
12932
|
rubricId: string2()
|
|
@@ -16857,7 +16838,7 @@ function pickString(record2, keys) {
|
|
|
16857
16838
|
// package.json
|
|
16858
16839
|
var package_default = {
|
|
16859
16840
|
name: "@uru-intelligence/cli",
|
|
16860
|
-
version: "0.4.
|
|
16841
|
+
version: "0.4.12",
|
|
16861
16842
|
private: false,
|
|
16862
16843
|
description: "Uru full-platform command line interface",
|
|
16863
16844
|
repository: {
|
|
@@ -16935,11 +16916,27 @@ var ExitCode = {
|
|
|
16935
16916
|
class CliError extends Error {
|
|
16936
16917
|
exitCode;
|
|
16937
16918
|
errorCode;
|
|
16919
|
+
confirmationRequired;
|
|
16920
|
+
suggestedCommand;
|
|
16921
|
+
errorId;
|
|
16922
|
+
httpStatus;
|
|
16938
16923
|
constructor(message, options = {}) {
|
|
16939
16924
|
super(message, options.cause === undefined ? undefined : { cause: options.cause });
|
|
16940
16925
|
this.name = "CliError";
|
|
16941
16926
|
this.exitCode = options.code ?? ExitCode.Failure;
|
|
16942
16927
|
this.errorCode = options.errorCode ?? defaultCliErrorCode(this.exitCode);
|
|
16928
|
+
if (options.confirmationRequired === true) {
|
|
16929
|
+
this.confirmationRequired = true;
|
|
16930
|
+
}
|
|
16931
|
+
if (options.suggestedCommand !== undefined) {
|
|
16932
|
+
this.suggestedCommand = options.suggestedCommand;
|
|
16933
|
+
}
|
|
16934
|
+
if (options.errorId !== undefined) {
|
|
16935
|
+
this.errorId = options.errorId;
|
|
16936
|
+
}
|
|
16937
|
+
if (options.httpStatus !== undefined) {
|
|
16938
|
+
this.httpStatus = options.httpStatus;
|
|
16939
|
+
}
|
|
16943
16940
|
}
|
|
16944
16941
|
}
|
|
16945
16942
|
function defaultCliErrorCode(exitCode) {
|
|
@@ -16957,6 +16954,9 @@ function defaultCliErrorCode(exitCode) {
|
|
|
16957
16954
|
}
|
|
16958
16955
|
}
|
|
16959
16956
|
|
|
16957
|
+
// src/oauth-credential.ts
|
|
16958
|
+
var SESSION_REFRESH_LEEWAY_MS = 5 * 60 * 1000;
|
|
16959
|
+
|
|
16960
16960
|
// ../../packages/types/src/mcp/gemResult.ts
|
|
16961
16961
|
var GEM_RESULT_SCHEMA_V1 = "uru.gem.result.v1";
|
|
16962
16962
|
// src/gem-result.ts
|
|
@@ -17009,6 +17009,7 @@ function gemToolError(operation, value) {
|
|
|
17009
17009
|
};
|
|
17010
17010
|
return new CliError(`Gem ${operation} failed: code=${error2.code}; message=${error2.message}; error_id=${error2.error_id}`, {
|
|
17011
17011
|
errorCode: error2.code,
|
|
17012
|
+
errorId: error2.error_id,
|
|
17012
17013
|
...error2.code === "source_revision_conflict" ? { code: ExitCode.Conflict } : {}
|
|
17013
17014
|
});
|
|
17014
17015
|
}
|
|
@@ -17145,6 +17146,40 @@ class UruApiClient {
|
|
|
17145
17146
|
}
|
|
17146
17147
|
return { streamed: false, payload: body.value };
|
|
17147
17148
|
}
|
|
17149
|
+
async requestSseStream(path, options = {}) {
|
|
17150
|
+
const query = buildQueryString(options.query);
|
|
17151
|
+
const signals = [this.signal, options.signal].filter((signal2) => signal2 !== undefined);
|
|
17152
|
+
const signal = signals.length === 0 ? undefined : signals.length === 1 ? signals[0] : AbortSignal.any(signals);
|
|
17153
|
+
const init = {
|
|
17154
|
+
method: options.method ?? "GET",
|
|
17155
|
+
...signal === undefined ? {} : { signal },
|
|
17156
|
+
headers: {
|
|
17157
|
+
Authorization: `Bearer ${this.token}`,
|
|
17158
|
+
Accept: "text/event-stream",
|
|
17159
|
+
"X-Uru-Client-Name": "uru-cli",
|
|
17160
|
+
"X-Uru-Client-Version": CLI_VERSION,
|
|
17161
|
+
...options.cliOperation === undefined ? {} : { "X-Uru-Client-Operation": options.cliOperation },
|
|
17162
|
+
...this.workspaceId === undefined ? {} : { "X-Uru-Workspace-Id": this.workspaceId },
|
|
17163
|
+
...options.lastEventId === undefined || options.lastEventId === "" ? {} : { "Last-Event-ID": options.lastEventId }
|
|
17164
|
+
}
|
|
17165
|
+
};
|
|
17166
|
+
const response = await this.fetchImpl(`${this.apiUrl}${path}${query}`, init);
|
|
17167
|
+
if (response.status === 404) {
|
|
17168
|
+
return { streamed: false, notFound: true };
|
|
17169
|
+
}
|
|
17170
|
+
if (response.ok && response.body !== null && isEventStreamResponse(response.headers.get("content-type"))) {
|
|
17171
|
+
return { streamed: true, stream: response.body };
|
|
17172
|
+
}
|
|
17173
|
+
const text = await response.text();
|
|
17174
|
+
const body = parseResponseBody(text);
|
|
17175
|
+
if (!body.parsed) {
|
|
17176
|
+
throw nonJsonResponseError(response.status, response.headers.get("content-type"));
|
|
17177
|
+
}
|
|
17178
|
+
if (!response.ok) {
|
|
17179
|
+
throw apiError(response.status, body.value, undefined);
|
|
17180
|
+
}
|
|
17181
|
+
throw new CliError("API returned a non-SSE runtime log stream.");
|
|
17182
|
+
}
|
|
17148
17183
|
async streamGemTool(name, parameters, operation, onEvent) {
|
|
17149
17184
|
const streamed = await this.streamTool(name, parameters, onEvent, operation);
|
|
17150
17185
|
if (streamed.streamed) {
|
|
@@ -17172,21 +17207,26 @@ function toolTransportError(body, requestBody) {
|
|
|
17172
17207
|
}
|
|
17173
17208
|
const status = body["httpStatus"];
|
|
17174
17209
|
const message = `${error2.message} (HTTP ${status})`;
|
|
17210
|
+
const structured = {
|
|
17211
|
+
...error2.errorCode === undefined ? {} : { errorCode: error2.errorCode },
|
|
17212
|
+
...error2.errorId === undefined ? {} : { errorId: error2.errorId },
|
|
17213
|
+
httpStatus: status
|
|
17214
|
+
};
|
|
17175
17215
|
if (status === 409) {
|
|
17176
17216
|
return new CliError(message, {
|
|
17177
17217
|
code: ExitCode.Conflict,
|
|
17178
|
-
...
|
|
17218
|
+
...structured
|
|
17179
17219
|
});
|
|
17180
17220
|
}
|
|
17181
17221
|
if (status === 401 || status === 403) {
|
|
17182
17222
|
return new CliError(message, {
|
|
17183
17223
|
code: ExitCode.AuthRequired,
|
|
17184
|
-
...
|
|
17224
|
+
...structured
|
|
17185
17225
|
});
|
|
17186
17226
|
}
|
|
17187
17227
|
return new CliError(message, {
|
|
17188
17228
|
code: error2.exitCode,
|
|
17189
|
-
...
|
|
17229
|
+
...structured
|
|
17190
17230
|
});
|
|
17191
17231
|
}
|
|
17192
17232
|
function normalizeApiUrl(value) {
|
|
@@ -17220,6 +17260,23 @@ function isNdjsonResponse(contentType) {
|
|
|
17220
17260
|
const normalized = String(contentType ?? "").toLowerCase();
|
|
17221
17261
|
return normalized.includes("application/x-ndjson") || normalized.includes("application/ndjson") || normalized.includes("text/x-ndjson");
|
|
17222
17262
|
}
|
|
17263
|
+
function isEventStreamResponse(contentType) {
|
|
17264
|
+
return String(contentType ?? "").toLowerCase().includes("text/event-stream");
|
|
17265
|
+
}
|
|
17266
|
+
function buildQueryString(query) {
|
|
17267
|
+
if (query === undefined) {
|
|
17268
|
+
return "";
|
|
17269
|
+
}
|
|
17270
|
+
const params = new URLSearchParams;
|
|
17271
|
+
for (const [key, value] of Object.entries(query)) {
|
|
17272
|
+
if (value === undefined || value === "") {
|
|
17273
|
+
continue;
|
|
17274
|
+
}
|
|
17275
|
+
params.set(key, String(value));
|
|
17276
|
+
}
|
|
17277
|
+
const encoded = params.toString();
|
|
17278
|
+
return encoded === "" ? "" : `?${encoded}`;
|
|
17279
|
+
}
|
|
17223
17280
|
async function readNdjsonStream(body, onEvent) {
|
|
17224
17281
|
const reader = body.getReader();
|
|
17225
17282
|
const decoder = new TextDecoder;
|
|
@@ -17286,9 +17343,12 @@ function apiError(status, payload, requestBody) {
|
|
|
17286
17343
|
"errorCode",
|
|
17287
17344
|
"error_code"
|
|
17288
17345
|
]);
|
|
17346
|
+
const errorId = pickStringFromJsonValue(envelope, ["errorId", "error_id"]);
|
|
17289
17347
|
return new CliError(message, {
|
|
17290
17348
|
code: status === 401 ? ExitCode.AuthRequired : ExitCode.Failure,
|
|
17291
|
-
errorCode: backendCode ?? (status === 401 ? "auth_required" : status === 403 ? "permission_denied" : "api_request_failed")
|
|
17349
|
+
errorCode: backendCode ?? (status === 401 ? "auth_required" : status === 403 ? "permission_denied" : "api_request_failed"),
|
|
17350
|
+
httpStatus: status,
|
|
17351
|
+
...errorId === undefined ? {} : { errorId }
|
|
17292
17352
|
});
|
|
17293
17353
|
}
|
|
17294
17354
|
function pickStringFromJsonValue(value, keys) {
|