@getstackrun/sdk 4.5.0 → 5.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 +16 -4
- package/dist/credentials-file.d.ts.map +1 -1
- package/dist/credentials-file.js +8 -2
- package/dist/credentials-file.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/key-resolver.d.ts +12 -0
- package/dist/key-resolver.d.ts.map +1 -0
- package/dist/key-resolver.js +19 -0
- package/dist/key-resolver.js.map +1 -0
- package/dist/network-install-key.d.ts +0 -2
- package/dist/network-install-key.d.ts.map +1 -1
- package/dist/network-install-key.js +2 -2
- package/dist/network-install-key.js.map +1 -1
- package/dist/service-mcp.d.ts +0 -5
- package/dist/service-mcp.d.ts.map +1 -1
- package/dist/service-mcp.js +1 -1
- package/dist/service-mcp.js.map +1 -1
- package/dist/services/accounts.d.ts +10 -28
- package/dist/services/accounts.d.ts.map +1 -1
- package/dist/services/accounts.js +3 -62
- package/dist/services/accounts.js.map +1 -1
- package/dist/services/agents.d.ts +13 -1
- package/dist/services/agents.d.ts.map +1 -1
- package/dist/services/agents.js +17 -5
- package/dist/services/agents.js.map +1 -1
- package/dist/services/control-socket.d.ts +1 -1
- package/dist/services/control-socket.d.ts.map +1 -1
- package/dist/services/control-socket.js +2 -0
- package/dist/services/control-socket.js.map +1 -1
- package/dist/services/live-stream.d.ts +34 -0
- package/dist/services/live-stream.d.ts.map +1 -0
- package/dist/services/live-stream.js +68 -0
- package/dist/services/live-stream.js.map +1 -0
- package/dist/services/llm.d.ts +3 -3
- package/dist/services/llm.d.ts.map +1 -1
- package/dist/services/meetings.d.ts +3 -17
- package/dist/services/meetings.d.ts.map +1 -1
- package/dist/services/meetings.js +2 -62
- package/dist/services/meetings.js.map +1 -1
- package/dist/services/memory.d.ts +5 -1
- package/dist/services/memory.d.ts.map +1 -1
- package/dist/services/memory.js +2 -1
- package/dist/services/memory.js.map +1 -1
- package/dist/services/passports.d.ts +10 -1
- package/dist/services/passports.d.ts.map +1 -1
- package/dist/services/passports.js +14 -0
- package/dist/services/passports.js.map +1 -1
- package/dist/services/rentahuman.d.ts +160 -72
- package/dist/services/rentahuman.d.ts.map +1 -1
- package/dist/services/rentahuman.js +53 -35
- package/dist/services/rentahuman.js.map +1 -1
- package/dist/services/security-events.d.ts +6 -1
- package/dist/services/security-events.d.ts.map +1 -1
- package/dist/services/security-events.js +5 -0
- package/dist/services/security-events.js.map +1 -1
- package/dist/services/services.d.ts +27 -5
- package/dist/services/services.d.ts.map +1 -1
- package/dist/services/services.js +41 -2
- package/dist/services/services.js.map +1 -1
- package/dist/services/skills.d.ts +2 -2
- package/dist/services/skills.d.ts.map +1 -1
- package/dist/services/skills.js.map +1 -1
- package/dist/types.d.ts +65 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/verify-agent-identity.d.ts.map +1 -1
- package/dist/verify-agent-identity.js +2 -17
- package/dist/verify-agent-identity.js.map +1 -1
- package/dist/verify-network.d.ts.map +1 -1
- package/dist/verify-network.js +2 -17
- package/dist/verify-network.js.map +1 -1
- package/dist/x402-pay.d.ts +0 -2
- package/dist/x402-pay.d.ts.map +1 -1
- package/dist/x402-pay.js +2 -2
- package/dist/x402-pay.js.map +1 -1
- package/package.json +4 -3
|
@@ -1,92 +1,180 @@
|
|
|
1
1
|
import type { HttpClient } from '../client.js';
|
|
2
|
-
import { type AgentWalletKey } from '../wallet-key.js';
|
|
3
2
|
import type { AccountAgentCallOptions } from './accounts.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
3
|
+
export interface RentAHumanBonus {
|
|
4
|
+
title: string;
|
|
5
|
+
condition: string;
|
|
6
|
+
/** What one earned item pays on top of base pay, in US cents (at least 50). */
|
|
7
|
+
unit_amount_cents: number;
|
|
8
|
+
max_units?: number;
|
|
9
|
+
}
|
|
10
|
+
export interface RentAHumanBonusDecision {
|
|
11
|
+
bonus_id: string;
|
|
12
|
+
earned_units: number;
|
|
13
|
+
reason?: string;
|
|
14
|
+
}
|
|
15
|
+
/** The job an agent wants posted. Prices are US cents. */
|
|
16
|
+
export interface RentAHumanJobInput {
|
|
17
|
+
title: string;
|
|
18
|
+
description: string;
|
|
19
|
+
/** Per worker, in US cents: the fixed price, or the hourly rate when `price_type` is `hourly`. From $1. */
|
|
20
|
+
price_cents: number;
|
|
21
|
+
price_type?: 'fixed' | 'hourly';
|
|
22
|
+
/** Expected working time per worker, in hours. */
|
|
23
|
+
estimated_hours?: number;
|
|
24
|
+
completion_criteria?: string;
|
|
25
|
+
evidence_types?: Array<'text' | 'photo' | 'video' | 'link' | 'document'>;
|
|
26
|
+
category?: 'computer-gigs' | 'creative-gigs' | 'crew-gigs' | 'domestic-gigs' | 'event-gigs' | 'labor-gigs' | 'talent-gigs' | 'writing-gigs';
|
|
27
|
+
skills_needed?: string[];
|
|
28
|
+
location?: {
|
|
29
|
+
city?: string;
|
|
30
|
+
state?: string;
|
|
31
|
+
country?: string;
|
|
32
|
+
remote_allowed?: boolean;
|
|
16
33
|
};
|
|
17
|
-
/**
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
34
|
+
/** How many workers (default 1). */
|
|
35
|
+
spots?: number;
|
|
36
|
+
/** ISO time applications close. */
|
|
37
|
+
applications_close_at?: string;
|
|
38
|
+
start_window_minutes?: number;
|
|
39
|
+
bonuses?: RentAHumanBonus[];
|
|
40
|
+
}
|
|
41
|
+
export interface RentAHumanJobPostInput extends RentAHumanJobInput {
|
|
42
|
+
/** 16 to 64 characters of letters, digits and `_ . : -`. Send the same key to retry a post: the retry is the same job, never a second charge. */
|
|
43
|
+
idempotency_key: string;
|
|
44
|
+
/** Refuses the post when the total would be above this many cents. */
|
|
45
|
+
max_total_cents?: number;
|
|
46
|
+
}
|
|
47
|
+
export interface RentAHumanJobQuote {
|
|
48
|
+
/** What the account's STACK balance is charged: worker pay, bonuses at their maximum and RentAHuman's service fee. */
|
|
49
|
+
total_cents: number;
|
|
50
|
+
seats: number;
|
|
51
|
+
per_seat: {
|
|
52
|
+
base_cents: number;
|
|
53
|
+
bonuses_cents: number;
|
|
54
|
+
fee_cents: number;
|
|
55
|
+
total_cents: number;
|
|
56
|
+
} | null;
|
|
57
|
+
}
|
|
58
|
+
export type RentAHumanJobState = 'creating' | 'funding' | 'capturing' | 'open' | 'refused' | 'failed' | 'closed';
|
|
59
|
+
export interface RentAHumanJob {
|
|
60
|
+
id: string;
|
|
61
|
+
account_id: string;
|
|
62
|
+
/** RentAHuman's id of the bounty; null until it is made. */
|
|
63
|
+
bounty_id: string | null;
|
|
64
|
+
state: RentAHumanJobState;
|
|
65
|
+
title: string;
|
|
66
|
+
/** What was held on the STACK balance. */
|
|
67
|
+
quoted_cents: number;
|
|
68
|
+
/** What the balance was charged (0 until the job is funded). */
|
|
69
|
+
charged_cents: number;
|
|
70
|
+
/** What went back to the balance (a cancel, unused money). */
|
|
71
|
+
refunded_cents: number;
|
|
72
|
+
/** RentAHuman's own status of the bounty, as last read. */
|
|
73
|
+
provider_status: string | null;
|
|
74
|
+
/** In plain words, why a job is waiting or did not go through. */
|
|
75
|
+
note: string | null;
|
|
76
|
+
created_at: string;
|
|
77
|
+
updated_at: string;
|
|
78
|
+
}
|
|
79
|
+
export interface RentAHumanJobList {
|
|
80
|
+
jobs: RentAHumanJob[];
|
|
81
|
+
}
|
|
82
|
+
/** What a person wrote, as third-party content: `untrusted` is always true, and `withheld` says when the scan held it back. */
|
|
83
|
+
export interface RentAHumanRead {
|
|
84
|
+
job_id: string;
|
|
85
|
+
untrusted: true;
|
|
86
|
+
items: unknown[];
|
|
87
|
+
withheld: {
|
|
88
|
+
security_event_id: string | null;
|
|
89
|
+
message: string;
|
|
90
|
+
} | null;
|
|
44
91
|
}
|
|
45
|
-
export interface
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
92
|
+
export interface RentAHumanDecisionInput {
|
|
93
|
+
action: 'accept' | 'reject';
|
|
94
|
+
response?: string;
|
|
95
|
+
}
|
|
96
|
+
export interface RentAHumanReviewInput {
|
|
97
|
+
action: 'approve' | 'reject' | 'request_redo';
|
|
98
|
+
/** Required for `reject` and `request_redo`: what the worker reads. */
|
|
99
|
+
response?: string;
|
|
100
|
+
bonus_decisions?: RentAHumanBonusDecision[];
|
|
101
|
+
}
|
|
102
|
+
export interface RentAHumanPayInput {
|
|
103
|
+
/** The application of the worker to pay (a job with several workers needs it). */
|
|
104
|
+
application_id?: string;
|
|
105
|
+
/** Paying the worker is final. This must be `true`. */
|
|
106
|
+
acknowledge_release: true;
|
|
107
|
+
bonus_decisions?: RentAHumanBonusDecision[];
|
|
108
|
+
}
|
|
109
|
+
export interface RentAHumanPay {
|
|
110
|
+
job_id: string;
|
|
111
|
+
paid: true;
|
|
112
|
+
escrow_id: string;
|
|
113
|
+
result: unknown;
|
|
114
|
+
}
|
|
115
|
+
export interface RentAHumanCancelInput {
|
|
116
|
+
/** Without it the call previews and returns one; with it the job is cancelled. */
|
|
117
|
+
confirmation_token?: string;
|
|
118
|
+
}
|
|
119
|
+
export interface RentAHumanCancel {
|
|
120
|
+
job: RentAHumanJob;
|
|
121
|
+
/** `preview`: nothing changed, confirm with the token. `cancelled`: done; what came back is credited to the balance. */
|
|
122
|
+
status: 'preview' | 'cancelled';
|
|
123
|
+
refund_cents: number | null;
|
|
124
|
+
confirmation_token: string | null;
|
|
125
|
+
}
|
|
126
|
+
export interface RentAHumanUnusedFundsInput {
|
|
127
|
+
/** Without it the call quotes; with the quote id it returns that money to the balance. */
|
|
128
|
+
quote_id?: string;
|
|
129
|
+
}
|
|
130
|
+
export interface RentAHumanUnusedFunds {
|
|
131
|
+
job: RentAHumanJob;
|
|
132
|
+
status: 'quote' | 'returned';
|
|
133
|
+
refundable_cents: number | null;
|
|
134
|
+
quote_id: string | null;
|
|
49
135
|
}
|
|
50
136
|
export interface RentAHumanConnection {
|
|
51
137
|
connection_id: string;
|
|
52
|
-
origin: 'owner_key'
|
|
138
|
+
origin: 'owner_key';
|
|
53
139
|
wake_registered: boolean;
|
|
54
140
|
created_at: string;
|
|
55
141
|
}
|
|
56
|
-
/** What the agent signs for a payment `join` or `fund` returned: Privy's authorization payload for the wallet's signing request. */
|
|
57
|
-
export declare function signRentAHumanPayment(key: AgentWalletKey, start: PaymentToSign): string;
|
|
58
142
|
export declare class RentAHumanService {
|
|
59
143
|
private readonly client;
|
|
60
144
|
constructor(client: HttpClient);
|
|
145
|
+
private jobs;
|
|
146
|
+
/** What a job would cost, before anything is held or charged. */
|
|
147
|
+
quoteJob(accountId: string, input: RentAHumanJobInput, options?: AccountAgentCallOptions): Promise<RentAHumanJobQuote>;
|
|
61
148
|
/**
|
|
62
|
-
*
|
|
63
|
-
* the
|
|
64
|
-
*/
|
|
65
|
-
join(accountId: string, input: RentAHumanJoinInput, options?: AccountAgentCallOptions): Promise<RentAHumanJoinStart>;
|
|
66
|
-
/**
|
|
67
|
-
* Step two: `signed` is the agent's signature (`signRentAHumanPayment`). Only the account's own agent, under its Passport. The
|
|
68
|
-
* payment goes through the wallet's per-payment and daily caps, the account's budget and the customer's decider; RentAHuman's key goes
|
|
69
|
-
* into the vault. Called again with the same `join_id` it answers the same and, when the account's events were not registered, tries again.
|
|
149
|
+
* Posts the job and charges the account's STACK balance (worker pay plus RentAHuman's 18% fee). The same `idempotency_key` is the same
|
|
150
|
+
* job. The answer is the job as it stands: one still being made answers with its `state` and `note` (HTTP 202); read it again with `getJob`.
|
|
70
151
|
*/
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
|
|
86
|
-
/**
|
|
152
|
+
postJob(accountId: string, input: RentAHumanJobPostInput, options?: AccountAgentCallOptions): Promise<RentAHumanJob>;
|
|
153
|
+
/** The account's jobs. */
|
|
154
|
+
listJobs(accountId: string, options?: AccountAgentCallOptions): Promise<RentAHumanJobList>;
|
|
155
|
+
getJob(accountId: string, jobId: string, options?: AccountAgentCallOptions): Promise<RentAHumanJob>;
|
|
156
|
+
/** The people who applied. What they wrote is untrusted text. */
|
|
157
|
+
listApplications(accountId: string, jobId: string, options?: AccountAgentCallOptions): Promise<RentAHumanRead>;
|
|
158
|
+
/** Accept or reject one application. */
|
|
159
|
+
decideApplication(accountId: string, jobId: string, applicationId: string, input: RentAHumanDecisionInput, options?: AccountAgentCallOptions): Promise<unknown>;
|
|
160
|
+
listConversations(accountId: string, jobId: string, options?: AccountAgentCallOptions): Promise<RentAHumanRead>;
|
|
161
|
+
/** One conversation with a worker. What they wrote is untrusted text. */
|
|
162
|
+
readConversation(accountId: string, jobId: string, conversationId: string, options?: AccountAgentCallOptions): Promise<RentAHumanRead>;
|
|
163
|
+
/** Writes to a worker in a conversation. */
|
|
164
|
+
sendMessage(accountId: string, jobId: string, conversationId: string, content: string, options?: AccountAgentCallOptions): Promise<unknown>;
|
|
165
|
+
/** What workers delivered. Untrusted text. */
|
|
166
|
+
listSubmissions(accountId: string, jobId: string, options?: AccountAgentCallOptions): Promise<RentAHumanRead>;
|
|
167
|
+
/** Approve a delivery, reject it, or ask for a redo (`response` is required for the last two). */
|
|
168
|
+
reviewSubmission(accountId: string, jobId: string, submissionId: string, input: RentAHumanReviewInput, options?: AccountAgentCallOptions): Promise<unknown>;
|
|
169
|
+
/** Pays the worker. Final: it cannot be taken back, and no further money leaves the balance (the job was charged when it was posted). */
|
|
170
|
+
payWorker(accountId: string, jobId: string, input: RentAHumanPayInput, options?: AccountAgentCallOptions): Promise<RentAHumanPay>;
|
|
171
|
+
/** Cancels in two calls: with no `confirmation_token` it previews what would come back and returns a token; send the token to cancel. */
|
|
172
|
+
cancelJob(accountId: string, jobId: string, input?: RentAHumanCancelInput, options?: AccountAgentCallOptions): Promise<RentAHumanCancel>;
|
|
173
|
+
/** Money left on a job, in two calls: with no `quote_id` it quotes; send the quote id to return that money to the STACK balance. */
|
|
174
|
+
returnUnusedFunds(accountId: string, jobId: string, input?: RentAHumanUnusedFundsInput, options?: AccountAgentCallOptions): Promise<RentAHumanUnusedFunds>;
|
|
175
|
+
/** The customer's own RentAHuman connection, or null when there is none. It shows no key. */
|
|
87
176
|
get(accountId: string, options?: AccountAgentCallOptions): Promise<{
|
|
88
177
|
connection: RentAHumanConnection | null;
|
|
89
178
|
}>;
|
|
90
179
|
}
|
|
91
|
-
export {};
|
|
92
180
|
//# sourceMappingURL=rentahuman.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rentahuman.d.ts","sourceRoot":"","sources":["../../src/services/rentahuman.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,
|
|
1
|
+
{"version":3,"file":"rentahuman.d.ts","sourceRoot":"","sources":["../../src/services/rentahuman.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAe7D,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IA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FAA6F;IACvF,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,uBAAuB,GAAG,OAAO,CAAC;QAAE,UAAU,EAAE,oBAAoB,GAAG,IAAI,CAAA;KAAE,CAAC;CAGtH"}
|
|
@@ -1,55 +1,73 @@
|
|
|
1
|
-
import { walletPaymentAuthorizationPayload } from '../wallet-key.js';
|
|
2
1
|
const seg = encodeURIComponent;
|
|
3
2
|
function passport(options) {
|
|
4
3
|
return options?.passportToken ? { headers: { 'X-Passport-Token': options.passportToken } } : undefined;
|
|
5
4
|
}
|
|
6
|
-
/** The two calls that pay from the wallet are made as the agent: the Passport is the bearer credential as well as `X-Passport-Token`. */
|
|
7
|
-
function asAgent(options) {
|
|
8
|
-
return options?.passportToken ? { headers: { 'X-Passport-Token': options.passportToken }, bearer: options.passportToken } : undefined;
|
|
9
|
-
}
|
|
10
|
-
/** What the agent signs for a payment `join` or `fund` returned: Privy's authorization payload for the wallet's signing request. */
|
|
11
|
-
export function signRentAHumanPayment(key, start) {
|
|
12
|
-
return key.sign(walletPaymentAuthorizationPayload({ appId: start.wallet.privy_app_id, walletId: start.wallet.wallet_id, typedData: start.typed_data }));
|
|
13
|
-
}
|
|
14
5
|
export class RentAHumanService {
|
|
15
6
|
client;
|
|
16
7
|
constructor(client) {
|
|
17
8
|
this.client = client;
|
|
18
9
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
async
|
|
24
|
-
return this.client.post(`/v1/accounts/${seg(accountId)}/rentahuman/
|
|
10
|
+
jobs(accountId, jobId) {
|
|
11
|
+
return `/v1/accounts/${seg(accountId)}/rentahuman/jobs${jobId === undefined ? '' : `/${seg(jobId)}`}`;
|
|
12
|
+
}
|
|
13
|
+
/** What a job would cost, before anything is held or charged. */
|
|
14
|
+
async quoteJob(accountId, input, options) {
|
|
15
|
+
return this.client.post(`/v1/accounts/${seg(accountId)}/rentahuman/quote`, input, passport(options));
|
|
25
16
|
}
|
|
26
17
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* into the vault. Called again with the same `join_id` it answers the same and, when the account's events were not registered, tries again.
|
|
18
|
+
* Posts the job and charges the account's STACK balance (worker pay plus RentAHuman's 18% fee). The same `idempotency_key` is the same
|
|
19
|
+
* job. The answer is the job as it stands: one still being made answers with its `state` and `note` (HTTP 202); read it again with `getJob`.
|
|
30
20
|
*/
|
|
31
|
-
async
|
|
32
|
-
return this.client.post(
|
|
21
|
+
async postJob(accountId, input, options) {
|
|
22
|
+
return this.client.post(this.jobs(accountId), input, passport(options));
|
|
23
|
+
}
|
|
24
|
+
/** The account's jobs. */
|
|
25
|
+
async listJobs(accountId, options) {
|
|
26
|
+
return this.client.get(this.jobs(accountId), undefined, passport(options));
|
|
27
|
+
}
|
|
28
|
+
async getJob(accountId, jobId, options) {
|
|
29
|
+
return this.client.get(this.jobs(accountId, jobId), undefined, passport(options));
|
|
30
|
+
}
|
|
31
|
+
/** The people who applied. What they wrote is untrusted text. */
|
|
32
|
+
async listApplications(accountId, jobId, options) {
|
|
33
|
+
return this.client.get(`${this.jobs(accountId, jobId)}/applications`, undefined, passport(options));
|
|
34
|
+
}
|
|
35
|
+
/** Accept or reject one application. */
|
|
36
|
+
async decideApplication(accountId, jobId, applicationId, input, options) {
|
|
37
|
+
return this.client.post(`${this.jobs(accountId, jobId)}/applications/${seg(applicationId)}`, input, passport(options));
|
|
38
|
+
}
|
|
39
|
+
async listConversations(accountId, jobId, options) {
|
|
40
|
+
return this.client.get(`${this.jobs(accountId, jobId)}/conversations`, undefined, passport(options));
|
|
41
|
+
}
|
|
42
|
+
/** One conversation with a worker. What they wrote is untrusted text. */
|
|
43
|
+
async readConversation(accountId, jobId, conversationId, options) {
|
|
44
|
+
return this.client.get(`${this.jobs(accountId, jobId)}/conversations/${seg(conversationId)}`, undefined, passport(options));
|
|
45
|
+
}
|
|
46
|
+
/** Writes to a worker in a conversation. */
|
|
47
|
+
async sendMessage(accountId, jobId, conversationId, content, options) {
|
|
48
|
+
return this.client.post(`${this.jobs(accountId, jobId)}/conversations/${seg(conversationId)}/messages`, { content }, passport(options));
|
|
49
|
+
}
|
|
50
|
+
/** What workers delivered. Untrusted text. */
|
|
51
|
+
async listSubmissions(accountId, jobId, options) {
|
|
52
|
+
return this.client.get(`${this.jobs(accountId, jobId)}/submissions`, undefined, passport(options));
|
|
33
53
|
}
|
|
34
|
-
/**
|
|
35
|
-
async
|
|
36
|
-
|
|
37
|
-
return this.completeJoin(accountId, { join_id: start.join_id, signed: signRentAHumanPayment(key, start) }, options);
|
|
54
|
+
/** Approve a delivery, reject it, or ask for a redo (`response` is required for the last two). */
|
|
55
|
+
async reviewSubmission(accountId, jobId, submissionId, input, options) {
|
|
56
|
+
return this.client.post(`${this.jobs(accountId, jobId)}/submissions/${seg(submissionId)}/review`, input, passport(options));
|
|
38
57
|
}
|
|
39
|
-
/**
|
|
40
|
-
async
|
|
41
|
-
return this.client.post(
|
|
58
|
+
/** Pays the worker. Final: it cannot be taken back, and no further money leaves the balance (the job was charged when it was posted). */
|
|
59
|
+
async payWorker(accountId, jobId, input, options) {
|
|
60
|
+
return this.client.post(`${this.jobs(accountId, jobId)}/pay`, input, passport(options));
|
|
42
61
|
}
|
|
43
|
-
/**
|
|
44
|
-
async
|
|
45
|
-
return this.client.post(
|
|
62
|
+
/** Cancels in two calls: with no `confirmation_token` it previews what would come back and returns a token; send the token to cancel. */
|
|
63
|
+
async cancelJob(accountId, jobId, input = {}, options) {
|
|
64
|
+
return this.client.post(`${this.jobs(accountId, jobId)}/cancel`, input, passport(options));
|
|
46
65
|
}
|
|
47
|
-
/**
|
|
48
|
-
async
|
|
49
|
-
|
|
50
|
-
return this.completeFund(accountId, { fund_id: start.fund_id, signed: signRentAHumanPayment(key, start) }, options);
|
|
66
|
+
/** Money left on a job, in two calls: with no `quote_id` it quotes; send the quote id to return that money to the STACK balance. */
|
|
67
|
+
async returnUnusedFunds(accountId, jobId, input = {}, options) {
|
|
68
|
+
return this.client.post(`${this.jobs(accountId, jobId)}/unused-funds`, input, passport(options));
|
|
51
69
|
}
|
|
52
|
-
/** The customer's RentAHuman connection, or null when there is none. It shows no key. */
|
|
70
|
+
/** The customer's own RentAHuman connection, or null when there is none. It shows no key. */
|
|
53
71
|
async get(accountId, options) {
|
|
54
72
|
return this.client.get(`/v1/accounts/${seg(accountId)}/rentahuman`, undefined, passport(options));
|
|
55
73
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rentahuman.js","sourceRoot":"","sources":["../../src/services/rentahuman.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rentahuman.js","sourceRoot":"","sources":["../../src/services/rentahuman.ts"],"names":[],"mappings":"AAgKA,MAAM,GAAG,GAAG,kBAAkB,CAAC;AAE/B,SAAS,QAAQ,CAAC,OAAiC;IACjD,OAAO,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,kBAAkB,EAAE,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AACzG,CAAC;AAED,MAAM,OAAO,iBAAiB;IACC;IAA7B,YAA6B,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;IAAG,CAAC;IAE3C,IAAI,CAAC,SAAiB,EAAE,KAAc;QAC5C,OAAO,gBAAgB,GAAG,CAAC,SAAS,CAAC,mBAAmB,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC;IACxG,CAAC;IAED,iEAAiE;IACjE,KAAK,CAAC,QAAQ,CAAC,SAAiB,EAAE,KAAyB,EAAE,OAAiC;QAC5F,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAqB,gBAAgB,GAAG,CAAC,SAAS,CAAC,mBAAmB,EAAE,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;IAC3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O,CAAC,CAAC,CAAC;IACjJ,CAAC;CACF"}
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import type { HttpClient } from '../client.js';
|
|
2
|
-
import type { SecurityEvent } from '../types.js';
|
|
2
|
+
import type { SecurityEvent, ListView } from '../types.js';
|
|
3
3
|
export declare class SecurityEventService {
|
|
4
4
|
private client;
|
|
5
5
|
constructor(client: HttpClient);
|
|
6
|
+
/**
|
|
7
|
+
* The account's unresolved events. `view: 'summary'` answers each event as a summary (`id`, `agent_id`, `signal_type`,
|
|
8
|
+
* `severity`, a short `message`, `created_at`); without a view, or with `full`, every field. `get` reads one in full.
|
|
9
|
+
*/
|
|
6
10
|
list(options?: {
|
|
7
11
|
agentId?: string;
|
|
8
12
|
page?: string;
|
|
9
13
|
limit?: string;
|
|
14
|
+
view?: ListView;
|
|
10
15
|
}): Promise<{
|
|
11
16
|
events: SecurityEvent[];
|
|
12
17
|
unresolved_count: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"security-events.d.ts","sourceRoot":"","sources":["../../src/services/security-events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"security-events.d.ts","sourceRoot":"","sources":["../../src/services/security-events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE3D,qBAAa,oBAAoB;IACnB,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,UAAU;IAEtC;;;OAGG;IACG,IAAI,CAAC,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,QAAQ,CAAA;KAAE,GAAG,OAAO,CAAC;QAClG,MAAM,EAAE,aAAa,EAAE,CAAC;QACxB,gBAAgB,EAAE,MAAM,CAAC;QACzB,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IASI,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAIvC,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,QAAQ,EAAE,OAAO,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;CAGtE"}
|
|
@@ -3,11 +3,16 @@ export class SecurityEventService {
|
|
|
3
3
|
constructor(client) {
|
|
4
4
|
this.client = client;
|
|
5
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* The account's unresolved events. `view: 'summary'` answers each event as a summary (`id`, `agent_id`, `signal_type`,
|
|
8
|
+
* `severity`, a short `message`, `created_at`); without a view, or with `full`, every field. `get` reads one in full.
|
|
9
|
+
*/
|
|
6
10
|
async list(options) {
|
|
7
11
|
return this.client.get('/v1/security-events', {
|
|
8
12
|
agent_id: options?.agentId,
|
|
9
13
|
page: options?.page,
|
|
10
14
|
limit: options?.limit,
|
|
15
|
+
view: options?.view,
|
|
11
16
|
});
|
|
12
17
|
}
|
|
13
18
|
async get(id) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"security-events.js","sourceRoot":"","sources":["../../src/services/security-events.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,oBAAoB;IACX;IAApB,YAAoB,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;IAAG,CAAC;IAE1C,KAAK,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"security-events.js","sourceRoot":"","sources":["../../src/services/security-events.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,oBAAoB;IACX;IAApB,YAAoB,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;IAAG,CAAC;IAE1C;;;OAGG;IACH,KAAK,CAAC,IAAI,CAAC,OAA8E;QAMvF,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,qBAAqB,EAAE;YAC5C,QAAQ,EAAE,OAAO,EAAE,OAAO;YAC1B,IAAI,EAAE,OAAO,EAAE,IAAI;YACnB,KAAK,EAAE,OAAO,EAAE,KAAK;YACrB,IAAI,EAAE,OAAO,EAAE,IAAI;SACpB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,EAAU;QAClB,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAgB,uBAAuB,EAAE,EAAE,CAAC,CAAC;IACrE,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,EAAU;QACtB,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,uBAAuB,EAAE,UAAU,CAAC,CAAC;IAC/D,CAAC;CACF"}
|
|
@@ -1,15 +1,30 @@
|
|
|
1
1
|
import type { HttpClient } from '../client.js';
|
|
2
|
-
import type { Service, ServiceConnection, ConnectServiceInput, ConnectCustomServiceInput, GrantAgentAccessInput, ConnectLink, CreateConnectLinkInput, CreatedConnectLink } from '../types.js';
|
|
2
|
+
import type { Service, ServiceConnection, ConnectServiceInput, ConnectCustomServiceInput, GrantAgentAccessInput, ConnectLink, CreateConnectLinkInput, CreatedConnectLink, AgentLosingAccess, DisconnectedConnection, ReplacementCredential, ServiceListQuery, ServiceListPage } from '../types.js';
|
|
3
3
|
import type { GrantAgentAccessResult } from './control-policies.js';
|
|
4
4
|
export declare class ServiceService {
|
|
5
5
|
private client;
|
|
6
6
|
constructor(client: HttpClient);
|
|
7
7
|
listAvailable(): Promise<Service[]>;
|
|
8
8
|
listConnected(): Promise<ServiceConnection[]>;
|
|
9
|
+
/**
|
|
10
|
+
* One page of the service catalogue, as summaries (`id`, `provider`, `name`, a short `description`) or, with
|
|
11
|
+
* `view: 'full'`, every field. `q` keeps the services whose provider, name or description contains the text. Pass the
|
|
12
|
+
* `next_cursor` of a page as `after` for the next; `total` counts the matches whatever the page. `listAvailable()` is
|
|
13
|
+
* the whole catalogue, unchanged.
|
|
14
|
+
*/
|
|
15
|
+
listAvailablePage(query?: ServiceListQuery): Promise<ServiceListPage>;
|
|
9
16
|
/** The API reads the credential from `oauth_token`; `provider` is not sent. */
|
|
10
17
|
connect(input: ConnectServiceInput): Promise<ServiceConnection>;
|
|
11
18
|
/** Rename a connection (owner or admin). Calls name it by the new name from then on; the id never changes. */
|
|
12
19
|
rename(connectionId: string, connectionName: string): Promise<ServiceConnection>;
|
|
20
|
+
/**
|
|
21
|
+
* Put a new key on a connection the account already holds, keeping its id, name and every agent's grant. `credential` is
|
|
22
|
+
* the field names and values a connect takes (a key service has one field, `api_key`). The key is sent in the request
|
|
23
|
+
* body only, never in the URL; the API checks it at the provider before it replaces the old one, and neither the key nor
|
|
24
|
+
* any hint of it is in the answer or the audit record. Owner or admin; an agent context is refused. Read the key from stdin
|
|
25
|
+
* or a vault, never a literal. To have the person type the key themselves, use `createConnectLink({ connection_id })`.
|
|
26
|
+
*/
|
|
27
|
+
replaceCredential(connectionId: string, credential: ReplacementCredential): Promise<ServiceConnection>;
|
|
13
28
|
/**
|
|
14
29
|
* Connect a service without the credential passing through this program or
|
|
15
30
|
* a chat: create a one-time link the person opens in their own browser,
|
|
@@ -20,7 +35,9 @@ export declare class ServiceService {
|
|
|
20
35
|
* name and the hosts the key may be sent to, which the page shows and the
|
|
21
36
|
* owner may correct there. Pass `connect` for a key of one of the customer's own supplier accounts (a print-on-demand
|
|
22
37
|
* supplier, an agent's Telegram bot, the street address's mailbox.bot key): the owner or an admin enters it on the page,
|
|
23
|
-
* so it never passes through this program or a chat.
|
|
38
|
+
* so it never passes through this program or a chat. Pass `connection_id` for a connection the account already holds: the
|
|
39
|
+
* link then replaces that connection's key, which keeps its id, name and grants (the `ConnectLink` reads back
|
|
40
|
+
* `replaces_connection_id`). An agent context is refused: an agent never adds credentials.
|
|
24
41
|
*/
|
|
25
42
|
createConnectLink(input: CreateConnectLinkInput): Promise<CreatedConnectLink>;
|
|
26
43
|
/** The state of a connect link: pending, connected (with the connection id) or expired. Never the URL. */
|
|
@@ -28,9 +45,14 @@ export declare class ServiceService {
|
|
|
28
45
|
/** The connect links still waiting for the person: pending and not yet expired, newest first, at most 50. Never a URL or a token. */
|
|
29
46
|
listConnectLinks(): Promise<ConnectLink[]>;
|
|
30
47
|
connectCustom(input: ConnectCustomServiceInput): Promise<ServiceConnection>;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Close a connection. Every agent's grant on it ends with it: the answer is the connection and `agents_losing_access`,
|
|
50
|
+
* the agents that held a grant (their Passports are revoked). Read the same list before disconnecting with
|
|
51
|
+
* {@link ServiceService.agentsHoldingGrants}.
|
|
52
|
+
*/
|
|
53
|
+
disconnect(connectionId: string): Promise<DisconnectedConnection>;
|
|
54
|
+
/** The agents that hold a grant on a connection: who would lose access if it were disconnected. Owner or admin; an agent is refused. */
|
|
55
|
+
agentsHoldingGrants(connectionId: string): Promise<AgentLosingAccess[]>;
|
|
34
56
|
/**
|
|
35
57
|
* Create or replace an agent's grant on a connection. With hosted controls on
|
|
36
58
|
* and a policy that lists connections, the answer carries `control_policy`:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"services.d.ts","sourceRoot":"","sources":["../../src/services/services.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EACV,OAAO,EACP,iBAAiB,EACjB,mBAAmB,EACnB,yBAAyB,EACzB,qBAAqB,EACrB,WAAW,EACX,sBAAsB,EACtB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"services.d.ts","sourceRoot":"","sources":["../../src/services/services.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KA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