@getstackrun/sdk 4.0.0 → 4.4.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/LICENSE +1 -1
- package/README.md +326 -10
- package/dist/agent-auth.d.ts.map +1 -1
- package/dist/agent-auth.js +3 -4
- package/dist/agent-auth.js.map +1 -1
- package/dist/browser-bootstrap.js +1 -1
- package/dist/browser-bootstrap.js.map +1 -1
- package/dist/client.d.ts +86 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +235 -40
- package/dist/client.js.map +1 -1
- package/dist/control-socket-server.d.ts +134 -0
- package/dist/control-socket-server.d.ts.map +1 -0
- package/dist/control-socket-server.js +108 -0
- package/dist/control-socket-server.js.map +1 -0
- package/dist/credentials-file.d.ts +7 -0
- package/dist/credentials-file.d.ts.map +1 -1
- package/dist/credentials-file.js +57 -2
- package/dist/credentials-file.js.map +1 -1
- package/dist/errors.d.ts +316 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +572 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +126 -24
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +150 -22
- package/dist/index.js.map +1 -1
- package/dist/network-install-key.d.ts +56 -0
- package/dist/network-install-key.d.ts.map +1 -0
- package/dist/network-install-key.js +92 -0
- package/dist/network-install-key.js.map +1 -0
- package/dist/network-install.d.ts +134 -0
- package/dist/network-install.d.ts.map +1 -0
- package/dist/network-install.js +70 -0
- package/dist/network-install.js.map +1 -0
- package/dist/service-mcp.d.ts +49 -0
- package/dist/service-mcp.d.ts.map +1 -0
- package/dist/service-mcp.js +122 -0
- package/dist/service-mcp.js.map +1 -0
- package/dist/services/accounts.d.ts +1548 -0
- package/dist/services/accounts.d.ts.map +1 -0
- package/dist/services/accounts.js +724 -0
- package/dist/services/accounts.js.map +1 -0
- package/dist/services/agent-identity.d.ts +58 -0
- package/dist/services/agent-identity.d.ts.map +1 -0
- package/dist/services/agent-identity.js +50 -0
- package/dist/services/agent-identity.js.map +1 -0
- package/dist/services/agents.d.ts +78 -3
- package/dist/services/agents.d.ts.map +1 -1
- package/dist/services/agents.js +29 -2
- package/dist/services/agents.js.map +1 -1
- package/dist/services/audit.d.ts +5 -0
- package/dist/services/audit.d.ts.map +1 -1
- package/dist/services/audit.js +5 -0
- package/dist/services/audit.js.map +1 -1
- package/dist/services/billing.d.ts +67 -0
- package/dist/services/billing.d.ts.map +1 -0
- package/dist/services/billing.js +42 -0
- package/dist/services/billing.js.map +1 -0
- package/dist/services/brain.d.ts +122 -0
- package/dist/services/brain.d.ts.map +1 -0
- package/dist/services/brain.js +40 -0
- package/dist/services/brain.js.map +1 -0
- package/dist/services/calendar.d.ts +256 -0
- package/dist/services/calendar.d.ts.map +1 -0
- package/dist/services/calendar.js +75 -0
- package/dist/services/calendar.js.map +1 -0
- package/dist/services/catalogue.d.ts +185 -0
- package/dist/services/catalogue.d.ts.map +1 -0
- package/dist/services/catalogue.js +31 -0
- package/dist/services/catalogue.js.map +1 -0
- package/dist/services/chat-channels.d.ts +82 -0
- package/dist/services/chat-channels.d.ts.map +1 -0
- package/dist/services/chat-channels.js +42 -0
- package/dist/services/chat-channels.js.map +1 -0
- package/dist/services/control-policies.d.ts +409 -0
- package/dist/services/control-policies.d.ts.map +1 -0
- package/dist/services/control-policies.js +101 -0
- package/dist/services/control-policies.js.map +1 -0
- package/dist/services/control-socket.d.ts +201 -0
- package/dist/services/control-socket.d.ts.map +1 -0
- package/dist/services/control-socket.js +165 -0
- package/dist/services/control-socket.js.map +1 -0
- package/dist/services/credentials.d.ts +2 -1
- package/dist/services/credentials.d.ts.map +1 -1
- package/dist/services/credentials.js +3 -2
- package/dist/services/credentials.js.map +1 -1
- package/dist/services/detector-config.d.ts +13 -12
- package/dist/services/detector-config.d.ts.map +1 -1
- package/dist/services/detector-config.js +13 -12
- package/dist/services/detector-config.js.map +1 -1
- package/dist/services/drive.d.ts +257 -0
- package/dist/services/drive.d.ts.map +1 -0
- package/dist/services/drive.js +167 -0
- package/dist/services/drive.js.map +1 -0
- package/dist/services/dropoffs.d.ts +5 -1
- package/dist/services/dropoffs.d.ts.map +1 -1
- package/dist/services/dropoffs.js +3 -1
- package/dist/services/dropoffs.js.map +1 -1
- package/dist/services/evidence-packs.d.ts +4 -2
- package/dist/services/evidence-packs.d.ts.map +1 -1
- package/dist/services/evidence-packs.js +4 -2
- package/dist/services/evidence-packs.js.map +1 -1
- package/dist/services/flagged-content.d.ts +30 -0
- package/dist/services/flagged-content.d.ts.map +1 -0
- package/dist/services/flagged-content.js +24 -0
- package/dist/services/flagged-content.js.map +1 -0
- package/dist/services/governance.d.ts +69 -0
- package/dist/services/governance.d.ts.map +1 -0
- package/dist/services/governance.js +39 -0
- package/dist/services/governance.js.map +1 -0
- package/dist/services/identity.d.ts +44 -4
- package/dist/services/identity.d.ts.map +1 -1
- package/dist/services/identity.js +54 -6
- package/dist/services/identity.js.map +1 -1
- package/dist/services/inbound-webhooks.d.ts +12 -1
- package/dist/services/inbound-webhooks.d.ts.map +1 -1
- package/dist/services/inbound-webhooks.js +7 -0
- package/dist/services/inbound-webhooks.js.map +1 -1
- package/dist/services/intents.d.ts +8 -2
- package/dist/services/intents.d.ts.map +1 -1
- package/dist/services/intents.js +7 -3
- package/dist/services/intents.js.map +1 -1
- package/dist/services/llm.d.ts +73 -1
- package/dist/services/llm.d.ts.map +1 -1
- package/dist/services/llm.js +62 -0
- package/dist/services/llm.js.map +1 -1
- package/dist/services/making.d.ts +263 -0
- package/dist/services/making.d.ts.map +1 -0
- package/dist/services/making.js +114 -0
- package/dist/services/making.js.map +1 -0
- package/dist/services/meetings.d.ts +183 -0
- package/dist/services/meetings.d.ts.map +1 -0
- package/dist/services/meetings.js +148 -0
- package/dist/services/meetings.js.map +1 -0
- package/dist/services/memory.d.ts +288 -0
- package/dist/services/memory.d.ts.map +1 -0
- package/dist/services/memory.js +116 -0
- package/dist/services/memory.js.map +1 -0
- package/dist/services/message-access.d.ts +50 -0
- package/dist/services/message-access.d.ts.map +1 -0
- package/dist/services/message-access.js +36 -0
- package/dist/services/message-access.js.map +1 -0
- package/dist/services/missions.d.ts +93 -7
- package/dist/services/missions.d.ts.map +1 -1
- package/dist/services/missions.js +29 -1
- package/dist/services/missions.js.map +1 -1
- package/dist/services/network.d.ts +266 -0
- package/dist/services/network.d.ts.map +1 -0
- package/dist/services/network.js +209 -0
- package/dist/services/network.js.map +1 -0
- package/dist/services/partner-accounts.d.ts +215 -0
- package/dist/services/partner-accounts.d.ts.map +1 -0
- package/dist/services/partner-accounts.js +133 -0
- package/dist/services/partner-accounts.js.map +1 -0
- package/dist/services/passports.d.ts +3 -2
- package/dist/services/passports.d.ts.map +1 -1
- package/dist/services/passports.js +3 -2
- package/dist/services/passports.js.map +1 -1
- package/dist/services/payments.d.ts +126 -0
- package/dist/services/payments.d.ts.map +1 -0
- package/dist/services/payments.js +66 -0
- package/dist/services/payments.js.map +1 -0
- package/dist/services/pii-config.d.ts +7 -17
- package/dist/services/pii-config.d.ts.map +1 -1
- package/dist/services/pii-config.js +9 -19
- package/dist/services/pii-config.js.map +1 -1
- package/dist/services/post.d.ts +240 -0
- package/dist/services/post.d.ts.map +1 -0
- package/dist/services/post.js +99 -0
- package/dist/services/post.js.map +1 -0
- package/dist/services/proxy.d.ts +20 -2
- package/dist/services/proxy.d.ts.map +1 -1
- package/dist/services/proxy.js +31 -1
- package/dist/services/proxy.js.map +1 -1
- package/dist/services/rentahuman.d.ts +92 -0
- package/dist/services/rentahuman.d.ts.map +1 -0
- package/dist/services/rentahuman.js +53 -0
- package/dist/services/rentahuman.js.map +1 -0
- package/dist/services/scan.d.ts +1 -1
- package/dist/services/scan.d.ts.map +1 -1
- package/dist/services/scan.js +1 -1
- package/dist/services/scan.js.map +1 -1
- package/dist/services/services.d.ts +28 -2
- package/dist/services/services.d.ts.map +1 -1
- package/dist/services/services.js +49 -1
- package/dist/services/services.js.map +1 -1
- package/dist/services/team.d.ts +13 -1
- package/dist/services/team.d.ts.map +1 -1
- package/dist/services/team.js +12 -0
- package/dist/services/team.js.map +1 -1
- package/dist/services/trust.d.ts +39 -0
- package/dist/services/trust.d.ts.map +1 -0
- package/dist/services/trust.js +35 -0
- package/dist/services/trust.js.map +1 -0
- package/dist/services/usage.d.ts +1 -1
- package/dist/services/usage.js +1 -1
- package/dist/services/wake.d.ts +257 -0
- package/dist/services/wake.d.ts.map +1 -0
- package/dist/services/wake.js +80 -0
- package/dist/services/wake.js.map +1 -0
- package/dist/services/website.d.ts +188 -0
- package/dist/services/website.d.ts.map +1 -0
- package/dist/services/website.js +135 -0
- package/dist/services/website.js.map +1 -0
- package/dist/types.d.ts +259 -25
- package/dist/types.d.ts.map +1 -1
- package/dist/verify-agent-identity.d.ts +73 -0
- package/dist/verify-agent-identity.d.ts.map +1 -0
- package/dist/verify-agent-identity.js +106 -0
- package/dist/verify-agent-identity.js.map +1 -0
- package/dist/verify-network.d.ts +159 -0
- package/dist/verify-network.d.ts.map +1 -0
- package/dist/verify-network.js +153 -0
- package/dist/verify-network.js.map +1 -0
- package/dist/wake-webhook.d.ts +57 -0
- package/dist/wake-webhook.d.ts.map +1 -0
- package/dist/wake-webhook.js +60 -0
- package/dist/wake-webhook.js.map +1 -0
- package/dist/wallet-key.d.ts +30 -0
- package/dist/wallet-key.d.ts.map +1 -0
- package/dist/wallet-key.js +108 -0
- package/dist/wallet-key.js.map +1 -0
- package/dist/webhook.d.ts +63 -0
- package/dist/webhook.d.ts.map +1 -0
- package/dist/webhook.js +136 -0
- package/dist/webhook.js.map +1 -0
- package/dist/x402-pay.d.ts +139 -0
- package/dist/x402-pay.d.ts.map +1 -0
- package/dist/x402-pay.js +235 -0
- package/dist/x402-pay.js.map +1 -0
- package/package.json +2 -1
- package/dist/services/partner-connect.d.ts +0 -64
- package/dist/services/partner-connect.d.ts.map +0 -1
- package/dist/services/partner-connect.js +0 -42
- package/dist/services/partner-connect.js.map +0 -1
- package/dist/services/partner-tenants.d.ts +0 -126
- package/dist/services/partner-tenants.d.ts.map +0 -1
- package/dist/services/partner-tenants.js +0 -79
- package/dist/services/partner-tenants.js.map +0 -1
|
@@ -16,19 +16,15 @@ import type { PiiConfig, PiiConfigUpdate } from '../types.js';
|
|
|
16
16
|
* lets you lower the threshold safely — bare-format personal numbers start
|
|
17
17
|
* redacting without every order number in your traffic going with them.
|
|
18
18
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* approves it in the dashboard, then you retry passing `governanceApprovalId`.
|
|
19
|
+
* Every change applies at once and asks no one, loosening included (redaction
|
|
20
|
+
* off, a higher threshold, a narrower country list). `direction` in the answer
|
|
21
|
+
* says which way it went.
|
|
23
22
|
*
|
|
24
23
|
* @example
|
|
25
24
|
* ```ts
|
|
26
25
|
* // A Nordic operator: only run SE/NO/DK schemes, and demand less
|
|
27
26
|
* // confidence because there is far less to confuse them with.
|
|
28
|
-
* await stack.piiConfig.update(
|
|
29
|
-
* { countries: ['SE', 'NO', 'DK'], threshold: 0.2 },
|
|
30
|
-
* { governanceApprovalId: 'gvr_...' },
|
|
31
|
-
* );
|
|
27
|
+
* await stack.piiConfig.update({ countries: ['SE', 'NO', 'DK'], threshold: 0.2 });
|
|
32
28
|
*
|
|
33
29
|
* const cfg = await stack.piiConfig.get();
|
|
34
30
|
* // { configured: true, enabled: true, threshold: 0.2, countries: ['SE','NO','DK'] }
|
|
@@ -47,15 +43,9 @@ export declare class PiiConfigService {
|
|
|
47
43
|
* Partial update. Omit a field to leave it untouched; pass `null` for
|
|
48
44
|
* `threshold` or `countries` to clear it back to the built-in default.
|
|
49
45
|
*/
|
|
50
|
-
update(input: PiiConfigUpdate
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
/** Delete the row and fall back to built-in defaults. Always needs the
|
|
54
|
-
* governance approval: the direction of a reset is not knowable in
|
|
55
|
-
* advance without reading the row being destroyed. */
|
|
56
|
-
reset(opts?: {
|
|
57
|
-
governanceApprovalId?: string;
|
|
58
|
-
}): Promise<{
|
|
46
|
+
update(input: PiiConfigUpdate): Promise<PiiConfig>;
|
|
47
|
+
/** Delete the row and fall back to built-in defaults. Applies at once. */
|
|
48
|
+
reset(): Promise<{
|
|
59
49
|
success: boolean;
|
|
60
50
|
}>;
|
|
61
51
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pii-config.d.ts","sourceRoot":"","sources":["../../src/services/pii-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9D
|
|
1
|
+
{"version":3,"file":"pii-config.d.ts","sourceRoot":"","sources":["../../src/services/pii-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,qBAAa,gBAAgB;IACf,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,UAAU;IAEtC;;;;OAIG;IACG,GAAG,IAAI,OAAO,CAAC,SAAS,CAAC;IAI/B;;;OAGG;IACG,MAAM,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,SAAS,CAAC;IAIxD,0EAA0E;IACpE,KAAK,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;CAG7C"}
|
|
@@ -14,19 +14,15 @@
|
|
|
14
14
|
* lets you lower the threshold safely — bare-format personal numbers start
|
|
15
15
|
* redacting without every order number in your traffic going with them.
|
|
16
16
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* approves it in the dashboard, then you retry passing `governanceApprovalId`.
|
|
17
|
+
* Every change applies at once and asks no one, loosening included (redaction
|
|
18
|
+
* off, a higher threshold, a narrower country list). `direction` in the answer
|
|
19
|
+
* says which way it went.
|
|
21
20
|
*
|
|
22
21
|
* @example
|
|
23
22
|
* ```ts
|
|
24
23
|
* // A Nordic operator: only run SE/NO/DK schemes, and demand less
|
|
25
24
|
* // confidence because there is far less to confuse them with.
|
|
26
|
-
* await stack.piiConfig.update(
|
|
27
|
-
* { countries: ['SE', 'NO', 'DK'], threshold: 0.2 },
|
|
28
|
-
* { governanceApprovalId: 'gvr_...' },
|
|
29
|
-
* );
|
|
25
|
+
* await stack.piiConfig.update({ countries: ['SE', 'NO', 'DK'], threshold: 0.2 });
|
|
30
26
|
*
|
|
31
27
|
* const cfg = await stack.piiConfig.get();
|
|
32
28
|
* // { configured: true, enabled: true, threshold: 0.2, countries: ['SE','NO','DK'] }
|
|
@@ -49,18 +45,12 @@ export class PiiConfigService {
|
|
|
49
45
|
* Partial update. Omit a field to leave it untouched; pass `null` for
|
|
50
46
|
* `threshold` or `countries` to clear it back to the built-in default.
|
|
51
47
|
*/
|
|
52
|
-
async update(input
|
|
53
|
-
return this.client.put('/v1/pii/config', input
|
|
54
|
-
? { headers: { 'X-Governance-Approval': opts.governanceApprovalId } }
|
|
55
|
-
: undefined);
|
|
48
|
+
async update(input) {
|
|
49
|
+
return this.client.put('/v1/pii/config', input);
|
|
56
50
|
}
|
|
57
|
-
/** Delete the row and fall back to built-in defaults.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
async reset(opts) {
|
|
61
|
-
return this.client.delete('/v1/pii/config', opts?.governanceApprovalId
|
|
62
|
-
? { headers: { 'X-Governance-Approval': opts.governanceApprovalId } }
|
|
63
|
-
: undefined);
|
|
51
|
+
/** Delete the row and fall back to built-in defaults. Applies at once. */
|
|
52
|
+
async reset() {
|
|
53
|
+
return this.client.delete('/v1/pii/config');
|
|
64
54
|
}
|
|
65
55
|
}
|
|
66
56
|
//# sourceMappingURL=pii-config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pii-config.js","sourceRoot":"","sources":["../../src/services/pii-config.ts"],"names":[],"mappings":"AAGA
|
|
1
|
+
{"version":3,"file":"pii-config.js","sourceRoot":"","sources":["../../src/services/pii-config.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,OAAO,gBAAgB;IACP;IAApB,YAAoB,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;IAAG,CAAC;IAE1C;;;;OAIG;IACH,KAAK,CAAC,GAAG;QACP,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAY,gBAAgB,CAAC,CAAC;IACtD,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,MAAM,CAAC,KAAsB;QACjC,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAY,gBAAgB,EAAE,KAAK,CAAC,CAAC;IAC7D,CAAC;IAED,0EAA0E;IAC1E,KAAK,CAAC,KAAK;QACT,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAuB,gBAAgB,CAAC,CAAC;IACpE,CAAC;CACF"}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import type { HttpClient } from '../client.js';
|
|
2
|
+
import type { AccountAgentCallOptions } from './accounts.js';
|
|
3
|
+
export type PostalAddressStatus = 'pending_identity' | 'active' | 'suspended' | 'closed';
|
|
4
|
+
export type PostalSuspendReason = 'supplier' | 'owner' | 'unpaid';
|
|
5
|
+
export type PostalItemKind = 'letter' | 'flat' | 'parcel';
|
|
6
|
+
export type PostalItemCustodyStatus = 'received' | 'stored' | 'held' | 'forwarding' | 'forwarded' | 'returning' | 'returned' | 'shredded' | 'disposed' | 'exception';
|
|
7
|
+
export type PostalRouting = 'routed' | 'pending' | 'unassigned';
|
|
8
|
+
/** How an agent reads an item: `offered` names no agent and any agent of the account may take it; `taken` was taken by `taken_by_agent_id`. */
|
|
9
|
+
export type PostalItemRouting = PostalRouting | 'offered' | 'taken';
|
|
10
|
+
export type PostalItemAction = 'scan' | 'forward' | 'shred';
|
|
11
|
+
export type PostalActionStatus = 'requested' | 'requires_approval' | 'approved' | 'in_progress' | 'done' | 'rejected' | 'failed' | 'cancelled';
|
|
12
|
+
/** `tracking_stopped`: still on its way 60 days after it was sent; STACK stopped following it, and the agent was told. */
|
|
13
|
+
export type LetterState = 'submitting' | 'sent' | 'in_transit' | 'delivered' | 'returned' | 'failed' | 'cancelled' | 'tracking_stopped';
|
|
14
|
+
/** A recipient or a forwarding destination. A US address needs a two-letter state. */
|
|
15
|
+
export interface PostalRecipientAddress {
|
|
16
|
+
name?: string;
|
|
17
|
+
company?: string;
|
|
18
|
+
line1: string;
|
|
19
|
+
line2?: string;
|
|
20
|
+
city: string;
|
|
21
|
+
state?: string;
|
|
22
|
+
postal_code: string;
|
|
23
|
+
/** ISO 3166-1 alpha-2, default US. */
|
|
24
|
+
country?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface PostalAddress {
|
|
27
|
+
id: string;
|
|
28
|
+
supplier: 'mailbox_bot';
|
|
29
|
+
status: PostalAddressStatus;
|
|
30
|
+
suspend_reason: PostalSuspendReason | null;
|
|
31
|
+
/** The supplier's own pages, where the customer signs up and completes Form 1583. Null once active. */
|
|
32
|
+
identity: {
|
|
33
|
+
url: string | null;
|
|
34
|
+
note: string | null;
|
|
35
|
+
};
|
|
36
|
+
address: {
|
|
37
|
+
street: string;
|
|
38
|
+
suite: string | null;
|
|
39
|
+
city: string | null;
|
|
40
|
+
state: string | null;
|
|
41
|
+
postal_code: string | null;
|
|
42
|
+
country: 'US';
|
|
43
|
+
} | null;
|
|
44
|
+
/** Where the supplier's webhook for this address points, and whether STACK holds a secret to check it. */
|
|
45
|
+
webhook: {
|
|
46
|
+
url: string;
|
|
47
|
+
signed: boolean;
|
|
48
|
+
};
|
|
49
|
+
/** What STACK charges monthly; null while the supplier bills the customer directly. */
|
|
50
|
+
monthly_fee_cents: number | null;
|
|
51
|
+
last_error_code: string | null;
|
|
52
|
+
activated_at: string | null;
|
|
53
|
+
created_at: string;
|
|
54
|
+
}
|
|
55
|
+
export interface ConnectPostalAddressInput {
|
|
56
|
+
/** The agent-scoped key created at the supplier. A sandbox key and the account-wide key are refused. */
|
|
57
|
+
api_key: string;
|
|
58
|
+
/** The `whsec_` secret of the webhook endpoint created at the supplier, for faster delivery. Optional. */
|
|
59
|
+
webhook_secret?: string;
|
|
60
|
+
}
|
|
61
|
+
/** What an agent prints on a form: its own line on the shared address. */
|
|
62
|
+
export interface AccountPostalAddress {
|
|
63
|
+
status: PostalAddressStatus;
|
|
64
|
+
mailing: {
|
|
65
|
+
attn: string;
|
|
66
|
+
street: string;
|
|
67
|
+
suite: string | null;
|
|
68
|
+
city: string | null;
|
|
69
|
+
state: string | null;
|
|
70
|
+
postal_code: string | null;
|
|
71
|
+
country: 'US';
|
|
72
|
+
} | null;
|
|
73
|
+
note: string;
|
|
74
|
+
}
|
|
75
|
+
export interface PostalItemActionView {
|
|
76
|
+
id: string;
|
|
77
|
+
action: PostalItemAction;
|
|
78
|
+
status: PostalActionStatus;
|
|
79
|
+
/** What the supplier quoted, in US cents. The supplier charges the owner's own account. */
|
|
80
|
+
quote_cents: number | null;
|
|
81
|
+
/** The message holding a scan's text, once it arrived. */
|
|
82
|
+
message_id: string | null;
|
|
83
|
+
created_at: string;
|
|
84
|
+
completed_at: string | null;
|
|
85
|
+
}
|
|
86
|
+
export interface PostalItem {
|
|
87
|
+
id: string;
|
|
88
|
+
reference_code: string | null;
|
|
89
|
+
kind: PostalItemKind;
|
|
90
|
+
custody_status: PostalItemCustodyStatus;
|
|
91
|
+
routing: PostalItemRouting;
|
|
92
|
+
account_id: string | null;
|
|
93
|
+
/** Set when `routing` is `taken`: the agent that took the item first. */
|
|
94
|
+
taken_by_agent_id: string | null;
|
|
95
|
+
/** The message that told the agent the item arrived. Its text is untrusted third-party content. */
|
|
96
|
+
message_id: string | null;
|
|
97
|
+
received_at: string;
|
|
98
|
+
actions: PostalItemActionView[];
|
|
99
|
+
}
|
|
100
|
+
export interface ListPostalItemsQuery {
|
|
101
|
+
/** 1 to 50, default 20. */
|
|
102
|
+
limit?: number;
|
|
103
|
+
cursor?: string;
|
|
104
|
+
/** The owner's list only. */
|
|
105
|
+
routing?: PostalRouting;
|
|
106
|
+
}
|
|
107
|
+
export interface ListPostalItemsResult {
|
|
108
|
+
items: PostalItem[];
|
|
109
|
+
next_cursor: string | null;
|
|
110
|
+
}
|
|
111
|
+
export interface AddressCheck {
|
|
112
|
+
deliverability: 'deliverable' | 'undeliverable';
|
|
113
|
+
provider_deliverability: string | null;
|
|
114
|
+
standardized: PostalRecipientAddress | null;
|
|
115
|
+
notes: string[];
|
|
116
|
+
}
|
|
117
|
+
interface SendCommon {
|
|
118
|
+
to: PostalRecipientAddress;
|
|
119
|
+
/** Who the post is from: the name on the return address, above the agent's line. Required, up to 40 characters. */
|
|
120
|
+
sender_name: string;
|
|
121
|
+
/** The sender address printed on the letter. Without it, the account's street address is used. Returned post goes to this address. A US address, checked like the recipient's. */
|
|
122
|
+
return_address?: PostalRecipientAddress;
|
|
123
|
+
/** 8 to 128 characters. Name each of two identical letters; the request itself is the default. */
|
|
124
|
+
idempotency_key?: string;
|
|
125
|
+
description?: string;
|
|
126
|
+
/** Promotion is `marketing`; the providers treat the two differently. Required. */
|
|
127
|
+
use_type: 'operational' | 'marketing';
|
|
128
|
+
}
|
|
129
|
+
export interface SendLetterInput extends SendCommon {
|
|
130
|
+
kind?: 'letter';
|
|
131
|
+
/** Plain text, or a PDF as base64 (4 MiB decoded; pages are the provider's own limit: Lob's 60 single-sided or 120 double-sided, 6 or 12 for a letter abroad). */
|
|
132
|
+
content: {
|
|
133
|
+
text: string;
|
|
134
|
+
} | {
|
|
135
|
+
pdf_base64: string;
|
|
136
|
+
};
|
|
137
|
+
color?: boolean;
|
|
138
|
+
double_sided?: boolean;
|
|
139
|
+
mail_class?: 'first_class' | 'standard';
|
|
140
|
+
/** Certified mail goes first class. */
|
|
141
|
+
extra_service?: 'certified' | 'certified_return_receipt';
|
|
142
|
+
}
|
|
143
|
+
export interface SendPostcardInput extends SendCommon {
|
|
144
|
+
kind: 'postcard';
|
|
145
|
+
size?: '4x6' | '6x9';
|
|
146
|
+
/** Text only: a postcard from a PDF is not offered. */
|
|
147
|
+
front: {
|
|
148
|
+
text: string;
|
|
149
|
+
};
|
|
150
|
+
back: {
|
|
151
|
+
text: string;
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
export interface Letter {
|
|
155
|
+
id: string;
|
|
156
|
+
account_id: string;
|
|
157
|
+
kind: 'letter' | 'postcard';
|
|
158
|
+
provider: 'lob' | 'postgrid';
|
|
159
|
+
/** `submitting` means the provider has not answered yet; STACK retries under the same key. */
|
|
160
|
+
state: LetterState;
|
|
161
|
+
/** SHA-256 of the content the provider was given; also in the signed record. */
|
|
162
|
+
content_sha256: string;
|
|
163
|
+
page_count: number | null;
|
|
164
|
+
recipient_country: string;
|
|
165
|
+
held_cents: number;
|
|
166
|
+
charged_cents: number | null;
|
|
167
|
+
expected_delivery: string | null;
|
|
168
|
+
preview_url: string | null;
|
|
169
|
+
events: Array<{
|
|
170
|
+
name: string;
|
|
171
|
+
occurred_at: string;
|
|
172
|
+
location: string | null;
|
|
173
|
+
}>;
|
|
174
|
+
last_error_code: string | null;
|
|
175
|
+
created_at: string;
|
|
176
|
+
sent_at: string | null;
|
|
177
|
+
}
|
|
178
|
+
export interface ListLettersQuery {
|
|
179
|
+
limit?: number;
|
|
180
|
+
cursor?: string;
|
|
181
|
+
}
|
|
182
|
+
export interface ListLettersResult {
|
|
183
|
+
letters: Letter[];
|
|
184
|
+
next_cursor: string | null;
|
|
185
|
+
}
|
|
186
|
+
export interface PostAgentCallOptions extends AccountAgentCallOptions {
|
|
187
|
+
/** Names one action; a retry with the same key and input is the same action. */
|
|
188
|
+
idempotencyKey?: string;
|
|
189
|
+
}
|
|
190
|
+
export declare class PostService {
|
|
191
|
+
private readonly client;
|
|
192
|
+
constructor(client: HttpClient);
|
|
193
|
+
/** What the address is and what it waits for. 404 before the owner starts one. */
|
|
194
|
+
getAddress(): Promise<PostalAddress>;
|
|
195
|
+
/** Start the address: the customer's own steps at the supplier come next (`identity.url`). */
|
|
196
|
+
startAddress(): Promise<PostalAddress>;
|
|
197
|
+
/** Hand over the agent key the customer created at the supplier. Never returned; never through a chat tool. */
|
|
198
|
+
connectAddress(input: ConnectPostalAddressInput): Promise<PostalAddress>;
|
|
199
|
+
/** Look at the supplier again now. */
|
|
200
|
+
refreshAddress(): Promise<PostalAddress>;
|
|
201
|
+
pauseAddress(): Promise<PostalAddress>;
|
|
202
|
+
/** Lifts the owner's own pause; an unpaid or supplier suspension is not the owner's to lift. */
|
|
203
|
+
resumeAddress(): Promise<PostalAddress>;
|
|
204
|
+
/** Disconnect: STACK forgets the supplier key and the mailbox's own details (its address, private mailbox number and ids). The mailbox at the supplier is untouched, and every item and scan already received stays. */
|
|
205
|
+
closeAddress(): Promise<PostalAddress>;
|
|
206
|
+
/** Every item at the address, including those no agent has taken yet (`routing: 'unassigned'`: offered to every agent of the account). */
|
|
207
|
+
listItems(q?: ListPostalItemsQuery): Promise<ListPostalItemsResult>;
|
|
208
|
+
/** Give an item that no agent has taken to an account. */
|
|
209
|
+
assignItem(itemId: string, accountId: string): Promise<PostalItem>;
|
|
210
|
+
/** The agent's own line on the address, to print on a form. */
|
|
211
|
+
accountAddress(accountId: string, options?: PostAgentCallOptions): Promise<AccountPostalAddress>;
|
|
212
|
+
listAccountItems(accountId: string, q?: ListPostalItemsQuery, options?: PostAgentCallOptions): Promise<ListPostalItemsResult>;
|
|
213
|
+
getAccountItem(accountId: string, itemId: string, options?: PostAgentCallOptions): Promise<PostalItem>;
|
|
214
|
+
/** Ask the supplier to open and scan an item. The owner approves at the supplier; the text then arrives as a message. */
|
|
215
|
+
scanItem(accountId: string, itemId: string, input?: {
|
|
216
|
+
capture?: 'document_pdf' | 'contents_photos' | 'both';
|
|
217
|
+
}, options?: PostAgentCallOptions): Promise<PostalItem>;
|
|
218
|
+
/** Ask the supplier to forward an item inside the US. */
|
|
219
|
+
forwardItem(accountId: string, itemId: string, input: {
|
|
220
|
+
destination: PostalRecipientAddress;
|
|
221
|
+
mail_class?: string;
|
|
222
|
+
}, options?: PostAgentCallOptions): Promise<PostalItem>;
|
|
223
|
+
/** Ask the supplier to shred an item. It cannot be undone, so the request says it knows. */
|
|
224
|
+
shredItem(accountId: string, itemId: string, options?: PostAgentCallOptions): Promise<PostalItem>;
|
|
225
|
+
/** Whether an address is deliverable, and the address as the provider standardises it. */
|
|
226
|
+
checkAddress(accountId: string, address: PostalRecipientAddress, options?: PostAgentCallOptions): Promise<AddressCheck>;
|
|
227
|
+
/**
|
|
228
|
+
* Send a letter (text or PDF) or a postcard (text). 201 when the provider
|
|
229
|
+
* took it, 202 while it has not answered yet (`state: 'submitting'`; STACK
|
|
230
|
+
* retries under the same key), 200 for a repeat of a request already made.
|
|
231
|
+
* Refused, with nothing held: prohibited content, an undeliverable address,
|
|
232
|
+
* no live street address.
|
|
233
|
+
*/
|
|
234
|
+
send(accountId: string, input: SendLetterInput | SendPostcardInput, options?: PostAgentCallOptions): Promise<Letter>;
|
|
235
|
+
listLetters(accountId: string, q?: ListLettersQuery, options?: PostAgentCallOptions): Promise<ListLettersResult>;
|
|
236
|
+
/** One letter with its tracking events. */
|
|
237
|
+
getLetter(accountId: string, letterId: string, options?: PostAgentCallOptions): Promise<Letter>;
|
|
238
|
+
}
|
|
239
|
+
export {};
|
|
240
|
+
//# sourceMappingURL=post.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"post.d.ts","sourceRoot":"","sources":["../../src/services/post.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAiB7D,MAAM,MAAM,mBAAmB,GAAG,kBAAkB,GAAG,QAAQ,GAAG,WAAW,GAAG,QAAQ,CAAC;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AAO,CAAC,UAAU,CAAC;IAIvG,0FAA0F;IACpF,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,sBAAsB,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,YAAY,CAAC;IAI7H;;;;;;OAMG;IACG,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,GAAG,iBAAiB,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,MAAM,CAAC;IAIpH,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC,GAAE,gBAAqB,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAI1H,2CAA2C;IACrC,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,MAAM,CAAC;CAGtG"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
const seg = encodeURIComponent;
|
|
2
|
+
function headers(options) {
|
|
3
|
+
const out = {};
|
|
4
|
+
if (options?.passportToken)
|
|
5
|
+
out['X-Passport-Token'] = options.passportToken;
|
|
6
|
+
if (options?.idempotencyKey)
|
|
7
|
+
out['Idempotency-Key'] = options.idempotencyKey;
|
|
8
|
+
return Object.keys(out).length > 0 ? { headers: out } : undefined;
|
|
9
|
+
}
|
|
10
|
+
function query(q) {
|
|
11
|
+
return { limit: q.limit !== undefined ? String(q.limit) : undefined, cursor: q.cursor, routing: q.routing };
|
|
12
|
+
}
|
|
13
|
+
export class PostService {
|
|
14
|
+
client;
|
|
15
|
+
constructor(client) {
|
|
16
|
+
this.client = client;
|
|
17
|
+
}
|
|
18
|
+
// ─── the customer's street address (owner or admin) ───────────────
|
|
19
|
+
/** What the address is and what it waits for. 404 before the owner starts one. */
|
|
20
|
+
async getAddress() {
|
|
21
|
+
return this.client.get('/v1/post/address');
|
|
22
|
+
}
|
|
23
|
+
/** Start the address: the customer's own steps at the supplier come next (`identity.url`). */
|
|
24
|
+
async startAddress() {
|
|
25
|
+
return this.client.post('/v1/post/address');
|
|
26
|
+
}
|
|
27
|
+
/** Hand over the agent key the customer created at the supplier. Never returned; never through a chat tool. */
|
|
28
|
+
async connectAddress(input) {
|
|
29
|
+
return this.client.post('/v1/post/address/connect', input);
|
|
30
|
+
}
|
|
31
|
+
/** Look at the supplier again now. */
|
|
32
|
+
async refreshAddress() {
|
|
33
|
+
return this.client.post('/v1/post/address/refresh');
|
|
34
|
+
}
|
|
35
|
+
async pauseAddress() {
|
|
36
|
+
return this.client.post('/v1/post/address/pause');
|
|
37
|
+
}
|
|
38
|
+
/** Lifts the owner's own pause; an unpaid or supplier suspension is not the owner's to lift. */
|
|
39
|
+
async resumeAddress() {
|
|
40
|
+
return this.client.post('/v1/post/address/resume');
|
|
41
|
+
}
|
|
42
|
+
/** Disconnect: STACK forgets the supplier key and the mailbox's own details (its address, private mailbox number and ids). The mailbox at the supplier is untouched, and every item and scan already received stays. */
|
|
43
|
+
async closeAddress() {
|
|
44
|
+
return this.client.delete('/v1/post/address');
|
|
45
|
+
}
|
|
46
|
+
/** Every item at the address, including those no agent has taken yet (`routing: 'unassigned'`: offered to every agent of the account). */
|
|
47
|
+
async listItems(q = {}) {
|
|
48
|
+
return this.client.get('/v1/post/items', query(q));
|
|
49
|
+
}
|
|
50
|
+
/** Give an item that no agent has taken to an account. */
|
|
51
|
+
async assignItem(itemId, accountId) {
|
|
52
|
+
return this.client.post(`/v1/post/items/${seg(itemId)}/assign`, { account_id: accountId });
|
|
53
|
+
}
|
|
54
|
+
// ─── an account's post ────────────────────────────────────────────
|
|
55
|
+
/** The agent's own line on the address, to print on a form. */
|
|
56
|
+
async accountAddress(accountId, options) {
|
|
57
|
+
return this.client.get(`/v1/accounts/${seg(accountId)}/post/address`, undefined, headers(options));
|
|
58
|
+
}
|
|
59
|
+
async listAccountItems(accountId, q = {}, options) {
|
|
60
|
+
return this.client.get(`/v1/accounts/${seg(accountId)}/post/items`, query(q), headers(options));
|
|
61
|
+
}
|
|
62
|
+
async getAccountItem(accountId, itemId, options) {
|
|
63
|
+
return this.client.get(`/v1/accounts/${seg(accountId)}/post/items/${seg(itemId)}`, undefined, headers(options));
|
|
64
|
+
}
|
|
65
|
+
/** Ask the supplier to open and scan an item. The owner approves at the supplier; the text then arrives as a message. */
|
|
66
|
+
async scanItem(accountId, itemId, input = {}, options) {
|
|
67
|
+
return this.client.post(`/v1/accounts/${seg(accountId)}/post/items/${seg(itemId)}/scan`, input, headers(options));
|
|
68
|
+
}
|
|
69
|
+
/** Ask the supplier to forward an item inside the US. */
|
|
70
|
+
async forwardItem(accountId, itemId, input, options) {
|
|
71
|
+
return this.client.post(`/v1/accounts/${seg(accountId)}/post/items/${seg(itemId)}/forward`, input, headers(options));
|
|
72
|
+
}
|
|
73
|
+
/** Ask the supplier to shred an item. It cannot be undone, so the request says it knows. */
|
|
74
|
+
async shredItem(accountId, itemId, options) {
|
|
75
|
+
return this.client.post(`/v1/accounts/${seg(accountId)}/post/items/${seg(itemId)}/shred`, { confirm: true }, headers(options));
|
|
76
|
+
}
|
|
77
|
+
/** Whether an address is deliverable, and the address as the provider standardises it. */
|
|
78
|
+
async checkAddress(accountId, address, options) {
|
|
79
|
+
return this.client.post(`/v1/accounts/${seg(accountId)}/post/address-check`, { address }, headers(options));
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Send a letter (text or PDF) or a postcard (text). 201 when the provider
|
|
83
|
+
* took it, 202 while it has not answered yet (`state: 'submitting'`; STACK
|
|
84
|
+
* retries under the same key), 200 for a repeat of a request already made.
|
|
85
|
+
* Refused, with nothing held: prohibited content, an undeliverable address,
|
|
86
|
+
* no live street address.
|
|
87
|
+
*/
|
|
88
|
+
async send(accountId, input, options) {
|
|
89
|
+
return this.client.post(`/v1/accounts/${seg(accountId)}/post/letters`, input, headers(options));
|
|
90
|
+
}
|
|
91
|
+
async listLetters(accountId, q = {}, options) {
|
|
92
|
+
return this.client.get(`/v1/accounts/${seg(accountId)}/post/letters`, query(q), headers(options));
|
|
93
|
+
}
|
|
94
|
+
/** One letter with its tracking events. */
|
|
95
|
+
async getLetter(accountId, letterId, options) {
|
|
96
|
+
return this.client.get(`/v1/accounts/${seg(accountId)}/post/letters/${seg(letterId)}`, undefined, headers(options));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=post.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"post.js","sourceRoot":"","sources":["../../src/services/post.ts"],"names":[],"mappings":"AAsMA,MAAM,GAAG,GAAG,kBAAkB,CAAC;AAE/B,SAAS,OAAO,CAAC,OAA8B;IAC7C,MAAM,GAAG,GAA2B,EAAE,CAAC;IACvC,IAAI,OAAO,EAAE,aAAa;QAAE,GAAG,CAAC,kBAAkB,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC;IAC5E,IAAI,OAAO,EAAE,cAAc;QAAE,GAAG,CAAC,iBAAiB,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC;IAC7E,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AACpE,CAAC;AAED,SAAS,KAAK,CAAC,CAAwD;IACrE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;AAC9G,CAAC;AAED,MAAM,OAAO,WAAW;IACO;IAA7B,YAA6B,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;IAAG,CAAC;IAEnD,qEAAqE;IAErE,kFA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,CAAC,EAAE,EAAE,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IAC9H,CAAC;CACF"}
|
package/dist/services/proxy.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { HttpClient } from '../client.js';
|
|
2
|
-
import type { ProxyOperation, ProxyOperationOptions, ProxyRequest, ProxyRequestOptions, ProxyResponse, ProxyUsage } from '../types.js';
|
|
2
|
+
import type { ProxyOperation, ProxyOperationOptions, ProxyRequest, ProxyRequestOptions, ProxyResponse, ProxyUsage, ServiceCallOptions } from '../types.js';
|
|
3
|
+
import { type ServiceToolList, type ServiceToolResult } from '../service-mcp.js';
|
|
3
4
|
export declare class ProxyService {
|
|
4
5
|
private client;
|
|
5
6
|
constructor(client: HttpClient);
|
|
@@ -15,15 +16,32 @@ export declare class ProxyService {
|
|
|
15
16
|
* the calling passport is in enforced mode — submit the intent
|
|
16
17
|
* first via `stack.intents.submitAndWait` and pass the returned
|
|
17
18
|
* `final.id` here.
|
|
19
|
+
* - `input.connection`: the connection to use when the service has several (its name, any case, or its `scon_` id); sent only
|
|
20
|
+
* when given.
|
|
18
21
|
* - `authorityRequestId`: stable operation handle. Non-GET calls create
|
|
19
22
|
* one before network I/O when omitted and expose it as
|
|
20
23
|
* `response.operationId` or `error.operationId`. Persist it and reuse
|
|
21
24
|
* it only for an unchanged retry.
|
|
22
25
|
*/
|
|
23
26
|
request(input: ProxyRequest, options?: ProxyRequestOptions): Promise<ProxyResponse>;
|
|
27
|
+
/**
|
|
28
|
+
* The tools a connected service that speaks MCP over HTTP offers (`tools/list`), sent through the credential proxy: the Passport,
|
|
29
|
+
* the Mission, the grant, the customer's decider, the meter and the audit record all apply. Works for any connected service whose
|
|
30
|
+
* connection carries its MCP address (`mcp_url`, given when it was connected) and for RentAHuman, whose address STACK knows. What comes
|
|
31
|
+
* back is the provider's words: `untrusted` is always true.
|
|
32
|
+
*/
|
|
33
|
+
serviceTools(service: string, options?: ServiceCallOptions): Promise<ServiceToolList>;
|
|
34
|
+
/**
|
|
35
|
+
* Call one tool of a connected service (`tools/call`) through the credential proxy. Reuse `authorityRequestId` for an exact retry of
|
|
36
|
+
* a call with an effect (posting or funding a bounty, sending a message): one id is one operation. A service's own error is thrown;
|
|
37
|
+
* a tool that reports an error in its result comes back with `is_error` true. The result is the provider's words: `untrusted`.
|
|
38
|
+
*/
|
|
39
|
+
serviceCallTool(service: string, tool: string, args?: Record<string, unknown>, options?: ServiceCallOptions): Promise<ServiceToolResult>;
|
|
40
|
+
/** The service's MCP address: its connection's own (never one a caller names; the proxy checks it against the connection's allowed hosts). */
|
|
41
|
+
private mcpUrl;
|
|
24
42
|
/** Read delivery state and, when authorized, the stored screened response. */
|
|
25
43
|
getOperation(operationId: string, options: ProxyOperationOptions): Promise<ProxyOperation>;
|
|
26
|
-
/** Month-to-date action pool. `pooled` is set on
|
|
44
|
+
/** Month-to-date action pool. `pooled` is set on the accounts of a partner on a negotiated hard cap. */
|
|
27
45
|
usage(): Promise<ProxyUsage>;
|
|
28
46
|
}
|
|
29
47
|
//# sourceMappingURL=proxy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../../src/services/proxy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EACV,cAAc,EACd,qBAAqB,EACrB,YAAY,EACZ,mBAAmB,EACnB,aAAa,EACb,UAAU,
|
|
1
|
+
{"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../../src/services/proxy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EACV,cAAc,EACd,qBAAqB,EACrB,YAAY,EACZ,mBAAmB,EACnB,aAAa,EACb,UAAU,EACV,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAErB,OAAO,EAKL,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACvB,MAAM,mBAAmB,CAAC;AA2B3B,qBAAa,YAAY;IACX,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,UAAU;IAEtC;;;;;;;;;;;;;;;;;;OAkBG;IACG,OAAO,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,aAAa,CAAC;IA2BzF;;;;;OAKG;IACG,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,eAAe,CAAC;IAQ3F;;;;OAIG;IACG,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAQlJ,8IAA8I;YAChI,MAAM;IAIpB,8EAA8E;IACxE,YAAY,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,cAAc,CAAC;IAShG,wGAAwG;IAClG,KAAK,IAAI,OAAO,CAAC,UAAU,CAAC;CAGnC"}
|
package/dist/services/proxy.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { authorityRequestHeaders, createAuthorityRequestId } from '../authority-request.js';
|
|
2
|
+
import { serviceMcpRequest, serviceMcpUrlOf, toolListOf, toolResultOf, } from '../service-mcp.js';
|
|
2
3
|
function normalizeProxyRequest(input) {
|
|
3
4
|
const candidate = input;
|
|
4
5
|
const hasService = candidate.service !== undefined;
|
|
@@ -13,6 +14,10 @@ function normalizeProxyRequest(input) {
|
|
|
13
14
|
const { service: _service, provider: _provider, ...request } = candidate;
|
|
14
15
|
return { ...request, service };
|
|
15
16
|
}
|
|
17
|
+
/** The `connection` selector of a call's options, sent only when given. */
|
|
18
|
+
function connectionOf(options) {
|
|
19
|
+
return options?.connection !== undefined ? { connection: options.connection } : {};
|
|
20
|
+
}
|
|
16
21
|
export class ProxyService {
|
|
17
22
|
client;
|
|
18
23
|
constructor(client) {
|
|
@@ -30,6 +35,8 @@ export class ProxyService {
|
|
|
30
35
|
* the calling passport is in enforced mode — submit the intent
|
|
31
36
|
* first via `stack.intents.submitAndWait` and pass the returned
|
|
32
37
|
* `final.id` here.
|
|
38
|
+
* - `input.connection`: the connection to use when the service has several (its name, any case, or its `scon_` id); sent only
|
|
39
|
+
* when given.
|
|
33
40
|
* - `authorityRequestId`: stable operation handle. Non-GET calls create
|
|
34
41
|
* one before network I/O when omitted and expose it as
|
|
35
42
|
* `response.operationId` or `error.operationId`. Persist it and reuse
|
|
@@ -62,12 +69,35 @@ export class ProxyService {
|
|
|
62
69
|
throw recoverable;
|
|
63
70
|
}
|
|
64
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* The tools a connected service that speaks MCP over HTTP offers (`tools/list`), sent through the credential proxy: the Passport,
|
|
74
|
+
* the Mission, the grant, the customer's decider, the meter and the audit record all apply. Works for any connected service whose
|
|
75
|
+
* connection carries its MCP address (`mcp_url`, given when it was connected) and for RentAHuman, whose address STACK knows. What comes
|
|
76
|
+
* back is the provider's words: `untrusted` is always true.
|
|
77
|
+
*/
|
|
78
|
+
async serviceTools(service, options) {
|
|
79
|
+
const response = await this.request({ service, url: await this.mcpUrl(service, options?.connection), method: 'POST', body: serviceMcpRequest('tools/list'), ...connectionOf(options) }, options);
|
|
80
|
+
return toolListOf(service, response);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Call one tool of a connected service (`tools/call`) through the credential proxy. Reuse `authorityRequestId` for an exact retry of
|
|
84
|
+
* a call with an effect (posting or funding a bounty, sending a message): one id is one operation. A service's own error is thrown;
|
|
85
|
+
* a tool that reports an error in its result comes back with `is_error` true. The result is the provider's words: `untrusted`.
|
|
86
|
+
*/
|
|
87
|
+
async serviceCallTool(service, tool, args = {}, options) {
|
|
88
|
+
const response = await this.request({ service, url: await this.mcpUrl(service, options?.connection), method: 'POST', body: serviceMcpRequest('tools/call', { name: tool, arguments: args }), ...connectionOf(options) }, options);
|
|
89
|
+
return toolResultOf(service, tool, response);
|
|
90
|
+
}
|
|
91
|
+
/** The service's MCP address: its connection's own (never one a caller names; the proxy checks it against the connection's allowed hosts). */
|
|
92
|
+
async mcpUrl(service, connection) {
|
|
93
|
+
return serviceMcpUrlOf(await this.client.get('/v1/services/connected'), service, connection);
|
|
94
|
+
}
|
|
65
95
|
/** Read delivery state and, when authorized, the stored screened response. */
|
|
66
96
|
async getOperation(operationId, options) {
|
|
67
97
|
authorityRequestHeaders(operationId);
|
|
68
98
|
return this.client.post('/v1/proxy/operations/get', { operation_id: operationId, include_response: options.includeResponse ?? false }, { headers: { 'X-Passport-Token': options.passportToken } });
|
|
69
99
|
}
|
|
70
|
-
/** Month-to-date action pool. `pooled` is set on
|
|
100
|
+
/** Month-to-date action pool. `pooled` is set on the accounts of a partner on a negotiated hard cap. */
|
|
71
101
|
async usage() {
|
|
72
102
|
return this.client.get('/v1/proxy/usage');
|
|
73
103
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.js","sourceRoot":"","sources":["../../src/services/proxy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"proxy.js","sourceRoot":"","sources":["../../src/services/proxy.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAC5F,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,UAAU,EACV,YAAY,GAGb,MAAM,mBAAmB,CAAC;AAI3B,SAAS,qBAAqB,CAAC,KAAmB;IAChD,MAAM,SAAS,GAAG,KAAiE,CAAC;IACpF,MAAM,UAAU,GAAG,SAAS,CAAC,OAAO,KAAK,SAAS,CAAC;IACnD,MAAM,WAAW,GAAG,SAAS,CAAC,QAAQ,KAAK,SAAS,CAAC;IAErD,IAAI,U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