@gravity-rail/cli 3.2.0 → 6.0.0
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/README.md +65 -32
- package/dist/{account-verify-phone-KOK7STAQ.js → account-verify-phone-IC7FNUQE.js} +5 -5
- package/dist/chunk-LQLGLI4Q.js +128 -0
- package/dist/chunk-LQLGLI4Q.js.map +1 -0
- package/dist/{chunk-INGVO35B.js → chunk-VA6G6IBW.js} +944 -13
- package/dist/chunk-VA6G6IBW.js.map +1 -0
- package/dist/{cli-client-context-NJgZhyfd.d.ts → cli-client-context-BVZdWMkY.d.ts} +2 -0
- package/dist/cli-utils.d.ts +22 -2
- package/dist/cli-utils.js +1 -1
- package/dist/errors-YBSCLOHE.js +13 -0
- package/dist/gr.js +9326 -5446
- package/dist/gr.js.map +1 -1
- package/dist/lib.d.ts +92 -7
- package/dist/lib.js +6893 -4609
- package/dist/lib.js.map +1 -1
- package/package.json +5 -5
- package/dist/chunk-3T7A5PSF.js +0 -59
- package/dist/chunk-3T7A5PSF.js.map +0 -1
- package/dist/chunk-INGVO35B.js.map +0 -1
- package/dist/chunk-WBFYLV7Q.js +0 -820
- package/dist/chunk-WBFYLV7Q.js.map +0 -1
- package/dist/errors-CFRLSAGA.js +0 -11
- /package/dist/{account-verify-phone-KOK7STAQ.js.map → account-verify-phone-IC7FNUQE.js.map} +0 -0
- /package/dist/{errors-CFRLSAGA.js.map → errors-YBSCLOHE.js.map} +0 -0
package/README.md
CHANGED
|
@@ -109,17 +109,6 @@ For **non-interactive** use (CI, scripts, code-interpreter sandboxes, or any mac
|
|
|
109
109
|
export GRAVITY_RAIL_API_KEY=your-api-key # set GRAVITY_RAIL_NO_BROWSER=1 to force the API-key hint
|
|
110
110
|
```
|
|
111
111
|
|
|
112
|
-
## Search the Documentation
|
|
113
|
-
|
|
114
|
-
Search without signing in or selecting a Workspace:
|
|
115
|
-
|
|
116
|
-
```sh
|
|
117
|
-
gr docs search -q "outbound workflow"
|
|
118
|
-
gr docs search -q "webhook signing" -o json
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
Table output shows page titles and URLs. JSON output includes `title`, `url`, `snippet`, and `score` for each result.
|
|
122
|
-
|
|
123
112
|
## Work with a Coding Agent
|
|
124
113
|
|
|
125
114
|
Give an agent the CLI's bootstrap instructions, then use each domain's `--help` to discover its commands:
|
|
@@ -269,6 +258,13 @@ so the agent picks it up on its next turn. Manager (`gr manage`) and Concierge
|
|
|
269
258
|
controls sends exactly what you typed. When stdin is not a TTY the prompt is
|
|
270
259
|
printed and left unanswered, and the turn ends normally.
|
|
271
260
|
|
|
261
|
+
**Proposed messages.** When the Manager wants to send an email from your Gmail
|
|
262
|
+
or a Slack or Teams message, it does not send it and does not pause: the draft
|
|
263
|
+
arrives as a tool result. With a TTY, `gr manage` prints it and asks **Send**,
|
|
264
|
+
**Discard** or **Not now**. Send and Discard settle it once, for every
|
|
265
|
+
surface. Not now, and any run without a TTY, leaves the draft open; open the
|
|
266
|
+
Chat on the web to edit it or decide later.
|
|
267
|
+
|
|
272
268
|
Approvals, access grants and checkout still **interrupt** the run and resume it
|
|
273
269
|
in place; unsupported interrupt types exit `3` with the JSON contract below.
|
|
274
270
|
|
|
@@ -301,7 +297,7 @@ not forwarded, as it may contain sensitive data. Use `resume.chatUuid` /
|
|
|
301
297
|
| `members` | Contacts and team — CRUD, labels, filters, roles, fields, import/export |
|
|
302
298
|
| `workspaces` | Workspace management — CRUD, features, themes, invitations, export/import |
|
|
303
299
|
| `workflows` | Conversational workflows — CRUD, notes, contributors, templates, analytics |
|
|
304
|
-
| `journeys` | Journey definitions — CRUD,
|
|
300
|
+
| `journeys` | Journey definitions — CRUD, authoring, drafts |
|
|
305
301
|
| `agents` | Autonomous AI members — CRUD, archive |
|
|
306
302
|
| `assistants` | AI personas — CRUD with model and voice configuration |
|
|
307
303
|
| `assignments` | Task-based conversations — CRUD, messages, tools |
|
|
@@ -313,7 +309,7 @@ not forwarded, as it may contain sensitive data. Use `resume.chatUuid` /
|
|
|
313
309
|
| `data-types` | Schema-driven forms and records — CRUD, field indexing, computed fields |
|
|
314
310
|
| `files` | Documents and folders — CRUD, sharing, semantic search, labels |
|
|
315
311
|
| `sites` | Customer portals — CRUD, pages, menus, web crawling |
|
|
316
|
-
| `events` |
|
|
312
|
+
| `events` | Event rules — triggers, CEL conditions, delayed actions |
|
|
317
313
|
| `calendars` | Scheduling — calendars, events, event types, availability, Google sync |
|
|
318
314
|
| `qualifications` | Workflow Scenarios, synthetic test runs, and criterion results |
|
|
319
315
|
| `queries` | Unified Query Engine — fields, validate, preview, run, syntax reference |
|
|
@@ -366,7 +362,7 @@ not forwarded, as it may contain sensitive data. Use `resume.chatUuid` /
|
|
|
366
362
|
| `apps` | OAuth app management |
|
|
367
363
|
| `oauth` | OAuth provider connections |
|
|
368
364
|
| `auth` | Two-factor authentication, credentials, and password management |
|
|
369
|
-
| `org` | Organization membership, invitations, and
|
|
365
|
+
| `org` | Organization membership, invitations, org domains, and webhooks |
|
|
370
366
|
|
|
371
367
|
## Recipes
|
|
372
368
|
|
|
@@ -418,7 +414,7 @@ gr pronunciations create -w $WORKSPACE --term "GravityRail" --respelling "GRA-vi
|
|
|
418
414
|
gr recordings download-url -w $WORKSPACE --chat-id 42
|
|
419
415
|
|
|
420
416
|
# Or download the WAV straight to a file.
|
|
421
|
-
gr recordings download -w $WORKSPACE --chat-id 42 -o call.wav
|
|
417
|
+
gr recordings download -w $WORKSPACE --chat-id 42 -o call.wav --allow-write
|
|
422
418
|
```
|
|
423
419
|
|
|
424
420
|
### Register and verify an org domain
|
|
@@ -529,21 +525,20 @@ gr concierge chat --sms --allow-write
|
|
|
529
525
|
|
|
530
526
|
If the API returns **412** `account_phone_unverified`, run `gr account verify-phone` first.
|
|
531
527
|
|
|
532
|
-
## Journey
|
|
528
|
+
## Journey authoring
|
|
533
529
|
|
|
534
530
|
The same commands are available through the internal `yarn gr` entry point.
|
|
535
531
|
All examples require workspace membership and `journeys:write` (which implies
|
|
536
532
|
`journeys:read`, also checked when cloning).
|
|
537
533
|
|
|
538
534
|
```sh
|
|
539
|
-
gr journeys create -w $WORKSPACE --data '{"name":"Onboarding
|
|
535
|
+
gr journeys create -w $WORKSPACE --data '{"name":"Onboarding","status":"draft"}' --allow-write
|
|
540
536
|
gr journeys authoring -w $WORKSPACE --id 42 -o json
|
|
541
|
-
gr journeys
|
|
542
|
-
gr journeys
|
|
543
|
-
gr journeys v2 clone -w $WORKSPACE --id 12 --allow-write
|
|
537
|
+
gr journeys definition put -w $WORKSPACE --id 42 --file definition.json --allow-write
|
|
538
|
+
gr journeys definition validate -w $WORKSPACE --id 42 -o json
|
|
544
539
|
```
|
|
545
540
|
|
|
546
|
-
`
|
|
541
|
+
`definition put` replaces the complete executable definition. Include `expectedUpdatedAt`
|
|
547
542
|
from the latest authoring read, ordered `touches`, and `endings`. Each touch can
|
|
548
543
|
carry `eventRules`, an incoming `wait`, and a `branch` with ordered routes.
|
|
549
544
|
Endings carry `celCondition` and/or `filterId` predicates and `eventRules`; they
|
|
@@ -585,8 +580,8 @@ owned by the route. For example, this branch selects Members with an email:
|
|
|
585
580
|
Use this object as a touch's `branch` in the complete definition. The owned
|
|
586
581
|
predicate is ANDed with any `filterId` and `celCondition`; it creates no saved
|
|
587
582
|
MemberFilter. Reading or changing it additionally requires `members:read` and
|
|
588
|
-
access to its fields. On `
|
|
589
|
-
and explicit `null` clears it. `
|
|
583
|
+
access to its fields. On `definition put`, omission preserves an existing owned predicate
|
|
584
|
+
and explicit `null` clears it. `definition validate` reports
|
|
590
585
|
`decision_rule_predicate_invalid` when a stored owned predicate cannot compile.
|
|
591
586
|
|
|
592
587
|
Existing steps and routes retain identity through their UUIDs. Omit a step or
|
|
@@ -599,9 +594,9 @@ To preserve an unfinished editor document without changing the executable
|
|
|
599
594
|
Journey, use the separate draft commands:
|
|
600
595
|
|
|
601
596
|
```sh
|
|
602
|
-
gr journeys
|
|
597
|
+
gr journeys draft put -w $WORKSPACE --id 42 --file draft.json --allow-write
|
|
603
598
|
gr journeys authoring -w $WORKSPACE --id 42 -o json
|
|
604
|
-
gr journeys
|
|
599
|
+
gr journeys draft delete -w $WORKSPACE --id 42 --expected-updated-at '2026-09-26T00:00:00Z' --allow-write
|
|
605
600
|
```
|
|
606
601
|
|
|
607
602
|
`draft.json` contains `expectedUpdatedAt` and `document` with `version`, `model`,
|
|
@@ -611,10 +606,25 @@ the executable definition. Neither draft command publishes a Journey.
|
|
|
611
606
|
|
|
612
607
|
Use `journeys update --id 42 --data '{"status":"active"}' --allow-write` to
|
|
613
608
|
publish, or `status: "paused"` to pause. Publishing runs server validation;
|
|
614
|
-
`
|
|
609
|
+
`definition validate` reports stored-definition issues without publishing. A stale
|
|
615
610
|
`expectedUpdatedAt` is rejected: reload and reconcile rather than blindly retrying.
|
|
616
|
-
|
|
617
|
-
|
|
611
|
+
|
|
612
|
+
Preview how a Journey would run for a Persona's test Member or a real Member.
|
|
613
|
+
The preview sends and writes nothing:
|
|
614
|
+
|
|
615
|
+
```sh
|
|
616
|
+
gr journeys simulate -w $WORKSPACE --id 42 --persona 7
|
|
617
|
+
gr journeys simulate -w $WORKSPACE --id 42 --member 1001 --source enrollment --until 2026-12-01T00:00:00Z
|
|
618
|
+
gr journeys simulate -w $WORKSPACE --id 42 --persona 7 --changes what-if.json --conversation-default noReply -o json
|
|
619
|
+
```
|
|
620
|
+
|
|
621
|
+
`--changes` holds an array of what-if changes, or an object with any of
|
|
622
|
+
`changes`, `conversationDefault` and `conversationOutcomes`. A change sets `target` to
|
|
623
|
+
`value` at `at`, or relative to a step or action with
|
|
624
|
+
`anchor: {kind: afterStep|afterAction|beforeStep, uuid, offsetSeconds?}`.
|
|
625
|
+
`--conversation-default` overrides the file. The default view prints one line
|
|
626
|
+
per event and the outcome, without values or message bodies; `-o json` prints
|
|
627
|
+
the full response.
|
|
618
628
|
|
|
619
629
|
## Workflow revision exports
|
|
620
630
|
|
|
@@ -702,24 +712,44 @@ not revoke the Bundle subscription.
|
|
|
702
712
|
| Edit package metadata | `bundles update --bundle <uuid> --name "Starter Kit" --description "Contents"` |
|
|
703
713
|
| Create a package | `bundles create --name "Starter Kit"` |
|
|
704
714
|
| Inspect/edit the package draft | `bundles draft get/set --bundle <uuid>` |
|
|
705
|
-
|
|
|
715
|
+
| See what the next version would change, publishing nothing | `bundles draft preview --bundle <uuid>` |
|
|
716
|
+
| Publish an immutable version: every Workflow's newest published revision and every other item as its source is now; prints what changes first | `bundles publish --bundle <uuid> --release-notes "What's new"` |
|
|
706
717
|
| Inspect summary and latest content | `bundles get --bundle <uuid>` |
|
|
707
718
|
| Inspect history or one version | `bundles versions/version --bundle <uuid>` |
|
|
708
719
|
| Share within the publisher organization | `bundles grant --bundle <uuid> --to organization --uuid <organization>` |
|
|
709
|
-
| Install the latest version (initially pinned) | `bundles install --bundle <uuid>` |
|
|
720
|
+
| Install the latest version (initially pinned; pre-selects the workspace default, when one exists and you hold `phones:read`, for phone slots the bindings leave out) | `bundles install --bundle <uuid>` |
|
|
710
721
|
| Follow new releases | `bundles policy --installation <uuid> --set auto` |
|
|
711
722
|
| Hold the installed release | `bundles policy --installation <uuid> --set pinned` |
|
|
712
723
|
| Detach: stop updates, keep installed content, make its Workflows editable | `bundles unsubscribe --installation <uuid>` |
|
|
713
724
|
| Preview an upgrade | `bundles preview --installation <uuid> --to 2` |
|
|
714
725
|
| Apply an upgrade | `bundles upgrade --installation <uuid> --to 2` |
|
|
715
726
|
| Inspect missing local dependencies | `bundles readiness --installation <uuid>` |
|
|
716
|
-
| Supply local dependencies | `bundles bind --installation <uuid> --bindings bindings.json` |
|
|
727
|
+
| Supply local dependencies (`{"kind": "new_phone_number"}` creates the installation's phone number; `{"kind": "provider_phone_number", "uuid": "<uuid>"}` creates one and links one of the organization's numbers to it, listed by `phone-numbers linkable`; an `operator_groups.<key>` slot takes `{"kind": "operator_group", "id": <group id>}`) | `bundles bind --installation <uuid> --bindings bindings.json` |
|
|
728
|
+
| Fill an Inbox slot by creating its Inbox: with an address now, on the platform domain (`--create-inbox`, `{"kind": "new_inbox"}`), or with no address yet, for an address on your organization's domain later (`--create-inbox-without-address`, `{"kind": "new_inbox_without_address"}`; it sends and receives nothing until given an address in its settings, and readiness reports it as waiting) | `bundles bind --installation <uuid> --create-inbox-without-address program.inbox` |
|
|
729
|
+
| Read per-workspace Ability settings | `bundles settings --installation <uuid>` |
|
|
730
|
+
| Change a filled Ability setting, a shared install field (one value several settings hold, such as the Pathways practice ID a Site and an Ability share), a Workflow's Inbox or phone number, the phone number or Inbox a Bundle's routing answers on, or the operator group it rings (a group is bound with, or after, an endpoint that rings it), without detaching | `bundles bind --installation <uuid> --bindings setting.json --replace` |
|
|
717
731
|
|
|
718
732
|
Commands require a workspace (`-w` or a workspace profile); mutations also require
|
|
719
733
|
`--allow-write`. Draft item files contain `{ "items": [...] }`; Workflow items
|
|
720
|
-
|
|
734
|
+
name `workflowUuid` and `revisionUuid`, and Form/Site items carry definitions.
|
|
721
735
|
Configuration is reusable software. Records and credentials stay local.
|
|
722
736
|
|
|
737
|
+
Publishing does not ship the revision a draft names: each Workflow goes out at
|
|
738
|
+
its newest published revision, and each Data Type (kind `form`), Journey, saved
|
|
739
|
+
filter and routing item is read from its source again (a Data Type definition
|
|
740
|
+
in the file is replaced by the source Data Type's). `bundles publish` prints
|
|
741
|
+
each item the version adds, changes or removes, a Workflow's revision before
|
|
742
|
+
and after, and each item whose newest state cannot go into a Bundle with a
|
|
743
|
+
closed reason and its status: `held` (it stays as the last published version
|
|
744
|
+
carried it, which can still go) or `blocked` (fix or remove it first: an item
|
|
745
|
+
the last published version did not carry, and so every item of a first version,
|
|
746
|
+
blocks the version when it cannot go, and so does a carried one whose last
|
|
747
|
+
published state cannot go either). It then
|
|
748
|
+
publishes exactly that list and refuses if it changed in between, or if nothing
|
|
749
|
+
would change. With `-o json` the published version carries the list as
|
|
750
|
+
`publishPlan`. `bundles draft preview` prints the same list and publishes
|
|
751
|
+
nothing; it needs no `--allow-write`.
|
|
752
|
+
|
|
723
753
|
For safe editing, retain `draftGeneration` from `bundles draft get -o json` and
|
|
724
754
|
pass it as `--expected-generation` to `draft set` or `publish`. Omitting it reads
|
|
725
755
|
the current generation just before the write and only detects changes during
|
|
@@ -746,6 +776,9 @@ unavailable while Form and Site definitions are copied at installation.
|
|
|
746
776
|
|
|
747
777
|
Create a Persona and Scenario in the Workflow Evaluate screen, or use
|
|
748
778
|
`gr personas create` and `gr qualifications scenarios create --file scenario.json`.
|
|
779
|
+
A Persona's test Member is created on first use; manage it with
|
|
780
|
+
`gr personas test-member get|create|reset --id <persona-id>` (`create` and `reset`
|
|
781
|
+
need `--allow-write`).
|
|
749
782
|
Pick the intended Member role for the Persona. If the Persona has no role, test
|
|
750
783
|
launch uses the workspace default Member role; missing or unsafe role setup must
|
|
751
784
|
be corrected by an authorized workspace administrator. The CLI never changes a
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
confirmAccountPhoneVerify,
|
|
3
|
-
requireAuth,
|
|
4
3
|
startAccountPhoneVerify
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import
|
|
7
|
-
|
|
4
|
+
} from "./chunk-LQLGLI4Q.js";
|
|
5
|
+
import {
|
|
6
|
+
requireAuth
|
|
7
|
+
} from "./chunk-VA6G6IBW.js";
|
|
8
8
|
|
|
9
9
|
// src/commands/account-verify-phone.ts
|
|
10
10
|
import * as readline from "readline/promises";
|
|
@@ -38,4 +38,4 @@ async function promptLine(question) {
|
|
|
38
38
|
export {
|
|
39
39
|
accountVerifyPhoneCommand
|
|
40
40
|
};
|
|
41
|
-
//# sourceMappingURL=account-verify-phone-
|
|
41
|
+
//# sourceMappingURL=account-verify-phone-IC7FNUQE.js.map
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
// src/lib/concierge-api.ts
|
|
2
|
+
function baseUrl(ctx) {
|
|
3
|
+
return `${ctx.envConfig.apiUrl}/api/v2/concierge`;
|
|
4
|
+
}
|
|
5
|
+
function authHeaders(ctx) {
|
|
6
|
+
return {
|
|
7
|
+
Authorization: `Bearer ${ctx.accessToken}`,
|
|
8
|
+
"Content-Type": "application/json"
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
function toCamelChat(raw) {
|
|
12
|
+
return {
|
|
13
|
+
id: raw.id,
|
|
14
|
+
uuid: raw.uuid,
|
|
15
|
+
chatType: raw.chatType,
|
|
16
|
+
title: raw.title,
|
|
17
|
+
threadId: raw.threadId,
|
|
18
|
+
createdAt: raw.createdAt,
|
|
19
|
+
updatedAt: raw.updatedAt
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function toCamelMessage(raw) {
|
|
23
|
+
return {
|
|
24
|
+
id: raw.id,
|
|
25
|
+
role: raw.role,
|
|
26
|
+
content: raw.content ?? "",
|
|
27
|
+
createdAt: raw.createdAt ?? null,
|
|
28
|
+
// Protocol-exempt snake_case on wire (see ConciergeMessageResponse)
|
|
29
|
+
toolCalls: raw.tool_calls ?? null,
|
|
30
|
+
toolCallId: raw.tool_call_id ?? null
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
async function listConciergeChats(ctx) {
|
|
34
|
+
const res = await fetch(`${baseUrl(ctx)}/chats`, { headers: authHeaders(ctx) });
|
|
35
|
+
if (!res.ok) throw new Error(`Failed to list concierge chats: ${res.status}`);
|
|
36
|
+
const data = await res.json();
|
|
37
|
+
return data.map(toCamelChat);
|
|
38
|
+
}
|
|
39
|
+
async function createConciergeChat(ctx, title) {
|
|
40
|
+
const res = await fetch(`${baseUrl(ctx)}/chats`, {
|
|
41
|
+
method: "POST",
|
|
42
|
+
headers: authHeaders(ctx),
|
|
43
|
+
body: JSON.stringify({ title: title ?? null })
|
|
44
|
+
});
|
|
45
|
+
if (!res.ok) throw new Error(`Failed to create concierge chat: ${res.status}`);
|
|
46
|
+
return toCamelChat(await res.json());
|
|
47
|
+
}
|
|
48
|
+
async function getConciergeChat(ctx, chatId) {
|
|
49
|
+
const res = await fetch(`${baseUrl(ctx)}/chats/${chatId}`, { headers: authHeaders(ctx) });
|
|
50
|
+
if (!res.ok) throw new Error(`Failed to get concierge chat ${chatId}: ${res.status}`);
|
|
51
|
+
return toCamelChat(await res.json());
|
|
52
|
+
}
|
|
53
|
+
async function originateConciergeCall(ctx, kind = "concierge_setup", outboundMessage, clientSurface) {
|
|
54
|
+
const body = { kind };
|
|
55
|
+
if (outboundMessage) body.outbound_message = outboundMessage;
|
|
56
|
+
if (clientSurface) body.client_surface = clientSurface;
|
|
57
|
+
const res = await fetch(`${baseUrl(ctx)}/calls`, {
|
|
58
|
+
method: "POST",
|
|
59
|
+
headers: authHeaders(ctx),
|
|
60
|
+
body: JSON.stringify(body)
|
|
61
|
+
});
|
|
62
|
+
if (res.status === 412) {
|
|
63
|
+
throw new Error("Your account phone is not verified. Run `gr account verify-phone` first.");
|
|
64
|
+
}
|
|
65
|
+
if (!res.ok) {
|
|
66
|
+
const detail = await res.text();
|
|
67
|
+
throw new Error(`Failed to start concierge call: ${res.status} ${detail}`);
|
|
68
|
+
}
|
|
69
|
+
return await res.json();
|
|
70
|
+
}
|
|
71
|
+
async function originateConciergeSms(ctx, kind = "concierge_setup") {
|
|
72
|
+
const res = await fetch(`${baseUrl(ctx)}/sms`, {
|
|
73
|
+
method: "POST",
|
|
74
|
+
headers: authHeaders(ctx),
|
|
75
|
+
body: JSON.stringify({ kind })
|
|
76
|
+
});
|
|
77
|
+
if (res.status === 412) {
|
|
78
|
+
throw new Error("Your account phone is not verified. Run `gr account verify-phone` first.");
|
|
79
|
+
}
|
|
80
|
+
if (!res.ok) {
|
|
81
|
+
const detail = await res.text();
|
|
82
|
+
throw new Error(`Failed to start concierge SMS: ${res.status} ${detail}`);
|
|
83
|
+
}
|
|
84
|
+
return await res.json();
|
|
85
|
+
}
|
|
86
|
+
async function startAccountPhoneVerify(ctx, phone) {
|
|
87
|
+
const res = await fetch(`${ctx.envConfig.apiUrl}/api/v2/account/phone/verify/start`, {
|
|
88
|
+
method: "POST",
|
|
89
|
+
headers: authHeaders(ctx),
|
|
90
|
+
body: JSON.stringify({ phone })
|
|
91
|
+
});
|
|
92
|
+
if (!res.ok) {
|
|
93
|
+
const detail = await res.text();
|
|
94
|
+
throw new Error(`Failed to send verification code: ${res.status} ${detail}`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
async function confirmAccountPhoneVerify(ctx, code) {
|
|
98
|
+
const res = await fetch(`${ctx.envConfig.apiUrl}/api/v2/account/phone/verify/confirm`, {
|
|
99
|
+
method: "POST",
|
|
100
|
+
headers: authHeaders(ctx),
|
|
101
|
+
body: JSON.stringify({ code })
|
|
102
|
+
});
|
|
103
|
+
if (!res.ok) {
|
|
104
|
+
const detail = await res.text();
|
|
105
|
+
throw new Error(`Failed to confirm verification code: ${res.status} ${detail}`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
async function getConciergeChatMessages(ctx, chatId) {
|
|
109
|
+
const res = await fetch(`${baseUrl(ctx)}/chats/${chatId}/messages`, {
|
|
110
|
+
headers: authHeaders(ctx)
|
|
111
|
+
});
|
|
112
|
+
if (!res.ok)
|
|
113
|
+
throw new Error(`Failed to get concierge messages for chat ${chatId}: ${res.status}`);
|
|
114
|
+
const data = await res.json();
|
|
115
|
+
return data.map(toCamelMessage);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export {
|
|
119
|
+
listConciergeChats,
|
|
120
|
+
createConciergeChat,
|
|
121
|
+
getConciergeChat,
|
|
122
|
+
originateConciergeCall,
|
|
123
|
+
originateConciergeSms,
|
|
124
|
+
startAccountPhoneVerify,
|
|
125
|
+
confirmAccountPhoneVerify,
|
|
126
|
+
getConciergeChatMessages
|
|
127
|
+
};
|
|
128
|
+
//# sourceMappingURL=chunk-LQLGLI4Q.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/concierge-api.ts"],"sourcesContent":["/**\n * Concierge API client — direct HTTP calls to the global concierge endpoints.\n *\n * The concierge is account-level (no workspace), so these bypass the ApiClient\n * which is workspace-oriented.\n */\n\nimport type { AuthenticatedContext } from './context';\n\nexport interface ConciergeChat {\n id: number;\n uuid: string;\n chatType: string;\n title: string | null;\n threadId: string;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface ConciergeMessage {\n id: string;\n role: string;\n content: string;\n createdAt: string | null;\n toolCalls: any[] | null;\n toolCallId: string | null;\n}\n\nfunction baseUrl(ctx: AuthenticatedContext): string {\n return `${ctx.envConfig.apiUrl}/api/v2/concierge`;\n}\n\nfunction authHeaders(ctx: AuthenticatedContext): Record<string, string> {\n return {\n Authorization: `Bearer ${ctx.accessToken}`,\n 'Content-Type': 'application/json',\n };\n}\n\n/**\n * Map GlobalChatResponse wire → local shape.\n *\n * App fields are camelCase only (we own both ends — no snake dual-read).\n * `tool_calls` / `tool_call_id` on messages stay snake_case intentionally\n * (OpenAI message protocol on ConciergeMessageResponse). (#19305)\n */\nfunction toCamelChat(raw: any): ConciergeChat {\n return {\n id: raw.id,\n uuid: raw.uuid,\n chatType: raw.chatType,\n title: raw.title,\n threadId: raw.threadId,\n createdAt: raw.createdAt,\n updatedAt: raw.updatedAt,\n };\n}\n\nfunction toCamelMessage(raw: any): ConciergeMessage {\n return {\n id: raw.id,\n role: raw.role,\n content: raw.content ?? '',\n createdAt: raw.createdAt ?? null,\n // Protocol-exempt snake_case on wire (see ConciergeMessageResponse)\n toolCalls: raw.tool_calls ?? null,\n toolCallId: raw.tool_call_id ?? null,\n };\n}\n\nexport async function listConciergeChats(ctx: AuthenticatedContext): Promise<ConciergeChat[]> {\n const res = await fetch(`${baseUrl(ctx)}/chats`, { headers: authHeaders(ctx) });\n if (!res.ok) throw new Error(`Failed to list concierge chats: ${res.status}`);\n const data = await res.json();\n return (data as any[]).map(toCamelChat);\n}\n\nexport async function createConciergeChat(\n ctx: AuthenticatedContext,\n title?: string\n): Promise<ConciergeChat> {\n const res = await fetch(`${baseUrl(ctx)}/chats`, {\n method: 'POST',\n headers: authHeaders(ctx),\n body: JSON.stringify({ title: title ?? null }),\n });\n if (!res.ok) throw new Error(`Failed to create concierge chat: ${res.status}`);\n return toCamelChat(await res.json());\n}\n\nexport async function getConciergeChat(\n ctx: AuthenticatedContext,\n chatId: number\n): Promise<ConciergeChat> {\n const res = await fetch(`${baseUrl(ctx)}/chats/${chatId}`, { headers: authHeaders(ctx) });\n if (!res.ok) throw new Error(`Failed to get concierge chat ${chatId}: ${res.status}`);\n return toCamelChat(await res.json());\n}\n\nexport interface ConciergeCallResult {\n callSid: string;\n startedAt: string;\n}\n\nexport interface ConciergeSmsResult {\n messageSid: string;\n conversationId: string;\n}\n\nexport async function originateConciergeCall(\n ctx: AuthenticatedContext,\n kind = 'concierge_setup',\n outboundMessage?: string,\n clientSurface?: string\n): Promise<ConciergeCallResult> {\n const body: Record<string, string | undefined> = { kind };\n if (outboundMessage) body.outbound_message = outboundMessage;\n if (clientSurface) body.client_surface = clientSurface;\n const res = await fetch(`${baseUrl(ctx)}/calls`, {\n method: 'POST',\n headers: authHeaders(ctx),\n body: JSON.stringify(body),\n });\n if (res.status === 412) {\n throw new Error('Your account phone is not verified. Run `gr account verify-phone` first.');\n }\n if (!res.ok) {\n const detail = await res.text();\n throw new Error(`Failed to start concierge call: ${res.status} ${detail}`);\n }\n return (await res.json()) as ConciergeCallResult;\n}\n\nexport async function originateConciergeSms(\n ctx: AuthenticatedContext,\n kind = 'concierge_setup'\n): Promise<ConciergeSmsResult> {\n const res = await fetch(`${baseUrl(ctx)}/sms`, {\n method: 'POST',\n headers: authHeaders(ctx),\n body: JSON.stringify({ kind }),\n });\n if (res.status === 412) {\n throw new Error('Your account phone is not verified. Run `gr account verify-phone` first.');\n }\n if (!res.ok) {\n const detail = await res.text();\n throw new Error(`Failed to start concierge SMS: ${res.status} ${detail}`);\n }\n return (await res.json()) as ConciergeSmsResult;\n}\n\nexport async function startAccountPhoneVerify(\n ctx: AuthenticatedContext,\n phone: string\n): Promise<void> {\n const res = await fetch(`${ctx.envConfig.apiUrl}/api/v2/account/phone/verify/start`, {\n method: 'POST',\n headers: authHeaders(ctx),\n body: JSON.stringify({ phone }),\n });\n if (!res.ok) {\n const detail = await res.text();\n throw new Error(`Failed to send verification code: ${res.status} ${detail}`);\n }\n}\n\nexport async function confirmAccountPhoneVerify(\n ctx: AuthenticatedContext,\n code: string\n): Promise<void> {\n const res = await fetch(`${ctx.envConfig.apiUrl}/api/v2/account/phone/verify/confirm`, {\n method: 'POST',\n headers: authHeaders(ctx),\n body: JSON.stringify({ code }),\n });\n if (!res.ok) {\n const detail = await res.text();\n throw new Error(`Failed to confirm verification code: ${res.status} ${detail}`);\n }\n}\n\nexport async function getConciergeChatMessages(\n ctx: AuthenticatedContext,\n chatId: number\n): Promise<ConciergeMessage[]> {\n const res = await fetch(`${baseUrl(ctx)}/chats/${chatId}/messages`, {\n headers: authHeaders(ctx),\n });\n if (!res.ok)\n throw new Error(`Failed to get concierge messages for chat ${chatId}: ${res.status}`);\n const data = await res.json();\n return (data as any[]).map(toCamelMessage);\n}\n"],"mappings":";AA4BA,SAAS,QAAQ,KAAmC;AACjD,SAAO,GAAG,IAAI,UAAU,MAAM;AACjC;AAEA,SAAS,YAAY,KAAmD;AACrE,SAAO;AAAA,IACJ,eAAe,UAAU,IAAI,WAAW;AAAA,IACxC,gBAAgB;AAAA,EACnB;AACH;AASA,SAAS,YAAY,KAAyB;AAC3C,SAAO;AAAA,IACJ,IAAI,IAAI;AAAA,IACR,MAAM,IAAI;AAAA,IACV,UAAU,IAAI;AAAA,IACd,OAAO,IAAI;AAAA,IACX,UAAU,IAAI;AAAA,IACd,WAAW,IAAI;AAAA,IACf,WAAW,IAAI;AAAA,EAClB;AACH;AAEA,SAAS,eAAe,KAA4B;AACjD,SAAO;AAAA,IACJ,IAAI,IAAI;AAAA,IACR,MAAM,IAAI;AAAA,IACV,SAAS,IAAI,WAAW;AAAA,IACxB,WAAW,IAAI,aAAa;AAAA;AAAA,IAE5B,WAA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