@forklaunch/core 3.2.1 → 3.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.
Files changed (59) hide show
  1. package/bin/gateway-mock/routes/payments-context.mjs +260 -0
  2. package/bin/gateway-mock/routes/payments.mjs +94 -1
  3. package/lib/agent/agent.d.ts +26 -0
  4. package/lib/agent/agent.d.ts.map +1 -0
  5. package/lib/agent/continuation.d.ts +29 -0
  6. package/lib/agent/continuation.d.ts.map +1 -0
  7. package/lib/agent/index.d.ts +8 -0
  8. package/lib/agent/index.d.ts.map +1 -0
  9. package/lib/agent/index.js +1049 -0
  10. package/lib/agent/index.js.map +1 -0
  11. package/lib/agent/index.mjs +1005 -0
  12. package/lib/agent/index.mjs.map +1 -0
  13. package/lib/agent/sources.d.ts +27 -0
  14. package/lib/agent/sources.d.ts.map +1 -0
  15. package/lib/agent/tools.d.ts +39 -0
  16. package/lib/agent/tools.d.ts.map +1 -0
  17. package/lib/agent/types.d.ts +130 -0
  18. package/lib/agent/types.d.ts.map +1 -0
  19. package/lib/http/bindRuntimeAuth.d.ts +53 -0
  20. package/lib/http/bindRuntimeAuth.d.ts.map +1 -0
  21. package/lib/http/bindRuntimeAuth.test.d.ts +2 -0
  22. package/lib/http/bindRuntimeAuth.test.d.ts.map +1 -0
  23. package/lib/http/index.d.ts +3 -0
  24. package/lib/http/index.d.ts.map +1 -1
  25. package/lib/http/index.js +487 -114
  26. package/lib/http/index.js.map +1 -1
  27. package/lib/http/index.mjs +484 -114
  28. package/lib/http/index.mjs.map +1 -1
  29. package/lib/http/localModelGatewayClient.d.ts +27 -0
  30. package/lib/http/localModelGatewayClient.d.ts.map +1 -0
  31. package/lib/http/mcpGenerator/mcpGenerator.d.ts.map +1 -1
  32. package/lib/http/middleware/internal/validationDiagnostic.d.ts +3 -0
  33. package/lib/http/middleware/internal/validationDiagnostic.d.ts.map +1 -0
  34. package/lib/http/middleware/request/auth.middleware.d.ts +0 -11
  35. package/lib/http/middleware/request/auth.middleware.d.ts.map +1 -1
  36. package/lib/http/middleware/request/parse.middleware.d.ts.map +1 -1
  37. package/lib/http/middleware/response/enrichExpressLikeSend.middleware.d.ts.map +1 -1
  38. package/lib/http/middleware/response/parse.middleware.d.ts.map +1 -1
  39. package/lib/http/modelGatewayClient.d.ts.map +1 -1
  40. package/lib/http/modelStream.d.ts +4 -0
  41. package/lib/http/modelStream.d.ts.map +1 -0
  42. package/lib/http/openApiV3Generator/openApiV3Generator.d.ts.map +1 -1
  43. package/lib/http/paymentsClient.d.ts +55 -1
  44. package/lib/http/paymentsClient.d.ts.map +1 -1
  45. package/lib/http/previewModelGatewayClient.d.ts +5 -1
  46. package/lib/http/previewModelGatewayClient.d.ts.map +1 -1
  47. package/lib/http/registerDelegatedSurface.d.ts +28 -0
  48. package/lib/http/registerDelegatedSurface.d.ts.map +1 -0
  49. package/lib/http/registerDelegatedSurface.test.d.ts +2 -0
  50. package/lib/http/registerDelegatedSurface.test.d.ts.map +1 -0
  51. package/lib/http/router/discriminateBody.d.ts +2 -1
  52. package/lib/http/router/discriminateBody.d.ts.map +1 -1
  53. package/lib/http/router/expressLikeRouter.d.ts.map +1 -1
  54. package/lib/ws/asyncApiV3Generator/asyncApiV3Generator.d.ts.map +1 -1
  55. package/lib/ws/index.js +94 -8
  56. package/lib/ws/index.js.map +1 -1
  57. package/lib/ws/index.mjs +94 -8
  58. package/lib/ws/index.mjs.map +1 -1
  59. package/package.json +12 -5
@@ -0,0 +1,260 @@
1
+ // Mirrors companion managed-apps/domain/services/payments-context.ts; tested by source conformance.
2
+ /** Read-only scoped protocol; never authorizes provider financial mutations. */
3
+ import { createHmac, timingSafeEqual } from "node:crypto";
4
+ export class PaymentContextError extends Error {
5
+ constructor() {
6
+ super("Payment context is unavailable or no longer matches");
7
+ }
8
+ }
9
+ function deny() {
10
+ throw new PaymentContextError();
11
+ }
12
+ const id = (v, prefix) => typeof v === "string" &&
13
+ v.length <= 128 &&
14
+ new RegExp(`^${prefix}[A-Za-z0-9_]+$`).test(v);
15
+ const uuid = (v) => typeof v === "string" &&
16
+ /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(v);
17
+ const apiVersion = (v) => typeof v === "string" && /^\d{4}-\d{2}-\d{2}(?:\.[a-z]+)?$/.test(v);
18
+ /** One immutable credential/base configuration, shared safely across requests. */
19
+ export class PaymentsContextProtocol {
20
+ forward;
21
+ now;
22
+ signingKey;
23
+ constructor(secret, base, forward, now = Date.now) {
24
+ this.forward = forward;
25
+ this.now = now;
26
+ if (!secret.trim() || secret.length > 4096)
27
+ deny();
28
+ let url;
29
+ try {
30
+ url = new URL(base);
31
+ }
32
+ catch {
33
+ deny();
34
+ }
35
+ if (!["http:", "https:"].includes(url.protocol) ||
36
+ url.username ||
37
+ url.password ||
38
+ url.search ||
39
+ url.hash)
40
+ deny();
41
+ const normalized = url.href.replace(/\/+$/, "");
42
+ this.clock();
43
+ this.signingKey = createHmac("sha256", secret)
44
+ .update(`forklaunch/payments-context/key/v1\0${normalized}`)
45
+ .digest();
46
+ }
47
+ clock() {
48
+ const value = this.now();
49
+ if (!Number.isSafeInteger(value) ||
50
+ value < 0 ||
51
+ value > Number.MAX_SAFE_INTEGER - 5000)
52
+ return deny();
53
+ return value;
54
+ }
55
+ mac(payload) {
56
+ return createHmac("sha256", this.signingKey)
57
+ .update(`forklaunch/payments-context/token/v1\0${payload}`)
58
+ .digest();
59
+ }
60
+ fresh(scope) {
61
+ const now = this.clock();
62
+ if (!Number.isSafeInteger(scope.issuedAt) ||
63
+ !Number.isSafeInteger(scope.expiresAt) ||
64
+ scope.expiresAt - scope.issuedAt !== 5000 ||
65
+ now < scope.issuedAt ||
66
+ now >= scope.expiresAt)
67
+ deny();
68
+ }
69
+ async same(scope, read) {
70
+ this.fresh(scope);
71
+ const row = await read();
72
+ this.fresh(scope);
73
+ if (!row ||
74
+ row.instanceId !== scope.instanceId ||
75
+ row.organizationId !== scope.organizationId ||
76
+ row.stripeAccountId !== scope.accountId ||
77
+ row.bindingGeneration !== scope.bindingGeneration)
78
+ deny();
79
+ }
80
+ async get(scope, path) {
81
+ this.fresh(scope);
82
+ const result = await this.forward({
83
+ method: "GET",
84
+ path,
85
+ query: "",
86
+ stripeAccount: scope.accountId,
87
+ stripeVersion: scope.apiVersion,
88
+ scopedReadTimeoutMs: Math.max(1, Math.floor(scope.expiresAt - this.clock())),
89
+ });
90
+ this.fresh(scope);
91
+ if (result.status < 200 ||
92
+ result.status >= 300 ||
93
+ Buffer.byteLength(result.body, "utf8") > 1024 * 1024)
94
+ deny();
95
+ let value;
96
+ try {
97
+ value = JSON.parse(result.body);
98
+ }
99
+ catch {
100
+ return deny();
101
+ }
102
+ if (!value || typeof value !== "object" || Array.isArray(value))
103
+ return deny();
104
+ return value;
105
+ }
106
+ async mode(scope) {
107
+ const balance = await this.get(scope, "/v1/balance");
108
+ if (balance.object !== "balance" || balance.livemode !== scope.livemode)
109
+ deny();
110
+ }
111
+ async issue(owner, request, read) {
112
+ const started = this.clock();
113
+ if (!id(request.accountId, "acct_") ||
114
+ typeof request.livemode !== "boolean" ||
115
+ !apiVersion(request.apiVersion))
116
+ return deny();
117
+ const row = await read();
118
+ if (!row ||
119
+ !uuid(row.bindingGeneration) ||
120
+ row.instanceId !== owner.id ||
121
+ row.organizationId !== owner.organizationId ||
122
+ row.stripeAccountId !== request.accountId)
123
+ return deny();
124
+ const scope = {
125
+ version: 1,
126
+ instanceId: owner.id,
127
+ organizationId: owner.organizationId,
128
+ accountId: row.stripeAccountId,
129
+ livemode: request.livemode,
130
+ bindingGeneration: row.bindingGeneration,
131
+ apiVersion: request.apiVersion,
132
+ issuedAt: started,
133
+ expiresAt: started + 5000,
134
+ };
135
+ const account = await this.get(scope, `/v1/accounts/${scope.accountId}`);
136
+ if (account.object !== "account" || account.id !== scope.accountId)
137
+ deny();
138
+ await this.mode(scope);
139
+ await this.same(scope, read);
140
+ const payload = Buffer.from(JSON.stringify(scope)).toString("base64url");
141
+ return {
142
+ scope,
143
+ contextToken: `${payload}.${this.mac(payload).toString("base64url")}`,
144
+ };
145
+ }
146
+ checkout(owner, request, read) {
147
+ return this.scopedRead("checkout", owner, request, read);
148
+ }
149
+ paymentLink(owner, request, read) {
150
+ return this.scopedRead("payment-link", owner, request, read);
151
+ }
152
+ /** Fixed paired evidence read; never exposes an arbitrary event/proxy route. */
153
+ async pausedSubscription(owner, request, read) {
154
+ if (!id(request.eventId, "evt_") || !id(request.subscriptionId, "sub_"))
155
+ return deny();
156
+ const scope = this.readScope(owner, request);
157
+ await this.same(scope, read);
158
+ await this.mode(scope);
159
+ await this.same(scope, read);
160
+ const event = await this.get(scope, `/v1/events/${request.eventId}`);
161
+ await this.same(scope, read);
162
+ if (event.id !== request.eventId ||
163
+ event.object !== "event" ||
164
+ event.type !== "customer.subscription.paused" ||
165
+ event.livemode !== scope.livemode ||
166
+ (event.account != null && event.account !== scope.accountId) ||
167
+ event.context != null ||
168
+ !Number.isSafeInteger(event.created) ||
169
+ event.created < 0)
170
+ return deny();
171
+ const data = event.data;
172
+ const prior = data?.object;
173
+ const before = this.pausedCustomer(prior, request.subscriptionId, scope);
174
+ const subscription = await this.get(scope, `/v1/subscriptions/${request.subscriptionId}`);
175
+ await this.same(scope, read);
176
+ if (this.pausedCustomer(subscription, request.subscriptionId, scope) !==
177
+ before)
178
+ return deny();
179
+ const result = { scope, event, subscription };
180
+ if (Buffer.byteLength(JSON.stringify(result), "utf8") > 1024 * 1024)
181
+ return deny();
182
+ this.fresh(scope);
183
+ return result;
184
+ }
185
+ pausedCustomer(value, subscriptionId, scope) {
186
+ if (!value || typeof value !== "object" || Array.isArray(value))
187
+ return deny();
188
+ const object = value;
189
+ if (object.id !== subscriptionId ||
190
+ object.object !== "subscription" ||
191
+ object.status !== "paused" ||
192
+ object.livemode !== scope.livemode)
193
+ return deny();
194
+ if (id(object.customer, "cus_"))
195
+ return object.customer;
196
+ const customer = object.customer;
197
+ if (!customer ||
198
+ typeof customer !== "object" ||
199
+ Array.isArray(customer) ||
200
+ customer.object !== "customer" ||
201
+ !id(customer.id, "cus_") ||
202
+ (Object.hasOwn(customer, "deleted") && customer.deleted !== false) ||
203
+ (Object.hasOwn(customer, "livemode") &&
204
+ customer.livemode !== scope.livemode))
205
+ return deny();
206
+ return customer.id;
207
+ }
208
+ readScope(owner, request) {
209
+ if (typeof request.contextToken !== "string" ||
210
+ request.contextToken.length > 4096)
211
+ return deny();
212
+ const parts = request.contextToken.split(".");
213
+ if (parts.length !== 2 || !parts.every((p) => /^[A-Za-z0-9_-]+$/.test(p)))
214
+ return deny();
215
+ const [payload, signature] = parts;
216
+ const actual = Buffer.from(signature, "base64url");
217
+ const expected = this.mac(payload);
218
+ if (actual.length !== expected.length ||
219
+ !timingSafeEqual(actual, expected) ||
220
+ actual.toString("base64url") !== signature)
221
+ return deny();
222
+ let scope;
223
+ try {
224
+ scope = JSON.parse(Buffer.from(payload, "base64url").toString("utf8"));
225
+ }
226
+ catch {
227
+ return deny();
228
+ }
229
+ if (!scope ||
230
+ scope.version !== 1 ||
231
+ scope.instanceId !== owner.id ||
232
+ scope.organizationId !== owner.organizationId ||
233
+ !id(scope.accountId, "acct_") ||
234
+ !uuid(scope.bindingGeneration) ||
235
+ typeof scope.livemode !== "boolean" ||
236
+ !apiVersion(scope.apiVersion) ||
237
+ scope.apiVersion !== request.apiVersion)
238
+ return deny();
239
+ return scope;
240
+ }
241
+ async scopedRead(kind, owner, request, read) {
242
+ if (typeof request.contextToken !== "string" ||
243
+ request.contextToken.length > 4096 ||
244
+ !id(request.id, kind === "checkout" ? "cs_" : "plink_"))
245
+ return deny();
246
+ const scope = this.readScope(owner, request);
247
+ await this.same(scope, read);
248
+ await this.mode(scope);
249
+ const object = await this.get(scope, kind === "checkout"
250
+ ? `/v1/checkout/sessions/${request.id}`
251
+ : `/v1/payment_links/${request.id}`);
252
+ if (object.id !== request.id ||
253
+ object.object !==
254
+ (kind === "checkout" ? "checkout.session" : "payment_link") ||
255
+ object.livemode !== scope.livemode)
256
+ deny();
257
+ await this.same(scope, read);
258
+ return { scope, object };
259
+ }
260
+ }
@@ -7,6 +7,10 @@
7
7
  * creates the instance's connected account
8
8
  * on first use (acct_mock_<n>)
9
9
  * GET /payments/status { chargesEnabled, payoutsEnabled, requirementsDue }
10
+ * GET /payments/payouts?limit=N { available, pending, payouts, bank, schedule }:
11
+ * empty before onboarding; once enabled, a
12
+ * balance and one paid payout (read-only)
13
+ * POST /payments/dashboard-link { url } once onboarded; 409 before
10
14
  * * /stripe/v1/... the Stripe API, as the real Stripe SDK
11
15
  * sends it (form-encoded, signed verbatim)
12
16
  *
@@ -41,7 +45,8 @@
41
45
  * http://localhost:12111 (docker stripe/stripe-mock)
42
46
  * MOCK_STRIPE_UPSTREAM_KEY the key sent upstream (default sk_test_123)
43
47
  */
44
- import { randomBytes } from 'node:crypto';
48
+ import { randomBytes, randomUUID } from 'node:crypto';
49
+ import { PaymentsContextProtocol } from './payments-context.mjs';
45
50
 
46
51
  const env = process.env;
47
52
  const AUTO_ENABLE = !['0', 'false', 'no'].includes(
@@ -446,6 +451,7 @@ async function onboardingLink(ctx) {
446
451
  ctx.state.accountCount = (ctx.state.accountCount ?? 0) + 1;
447
452
  account = ctx.state.accounts[ctx.instanceId] = {
448
453
  id: `acct_mock_${String(ctx.state.accountCount).padStart(4, '0')}`,
454
+ bindingGeneration: randomUUID(),
449
455
  chargesEnabled: false,
450
456
  payoutsEnabled: false,
451
457
  detailsSubmitted: false,
@@ -466,6 +472,87 @@ function status(ctx) {
466
472
  });
467
473
  }
468
474
 
475
+ /** Mirrors the platform: 1..50, 10 when missing or not a number. */
476
+ function payoutsLimit(raw) {
477
+ const n = raw === null || raw.trim() === '' ? NaN : Number(raw);
478
+ if (!Number.isFinite(n)) return 10;
479
+ return Math.min(50, Math.max(1, Math.floor(n)));
480
+ }
481
+
482
+ function payouts(ctx) {
483
+ const account = accountFor(ctx);
484
+ if (!account) {
485
+ return ctx.send(200, { available: [], pending: [], payouts: [], bank: null, schedule: null });
486
+ }
487
+ const limit = payoutsLimit(new URL(ctx.req.url ?? '/', 'http://mock').searchParams.get('limit'));
488
+ const enabled = Boolean(account.payoutsEnabled);
489
+ const day = 86_400_000;
490
+ return ctx.send(200, {
491
+ available: [{ amount: enabled ? 12_500 : 0, currency: 'usd' }],
492
+ pending: [{ amount: enabled ? 4_200 : 0, currency: 'usd' }],
493
+ payouts: enabled
494
+ ? [{
495
+ id: `po_mock_${account.id.slice(-4)}`,
496
+ amount: 9_900,
497
+ currency: 'usd',
498
+ status: 'paid',
499
+ arrivalDate: new Date(Date.now() - 2 * day).toISOString(),
500
+ automatic: true
501
+ }].slice(0, limit)
502
+ : [],
503
+ bank: enabled ? { bankName: 'STRIPE TEST BANK', last4: '6789' } : null,
504
+ schedule: enabled ? { interval: 'daily', delayDays: 2 } : null
505
+ });
506
+ }
507
+
508
+ function dashboardLink(ctx) {
509
+ const account = accountFor(ctx);
510
+ if (!account?.detailsSubmitted) {
511
+ return ctx.send(409, 'Payments are not set up yet: finish Stripe onboarding first');
512
+ }
513
+ return ctx.send(200, { url: `https://connect.stripe.com/express/${account.id}/mock_${randomBytes(6).toString('hex')}` });
514
+ }
515
+
516
+ // Dedicated context routes never widen STRIPE_ALLOWLIST. Synthetic mode is
517
+ // test-only; configured upstream verifies its own actual account and mode.
518
+ async function scopedRead(ctx, operation) {
519
+ const read = async () => {
520
+ const account = accountFor(ctx);
521
+ return account ? {instanceId:ctx.instanceId, organizationId:`mock:${ctx.instanceId}`,
522
+ stripeAccountId:account.id, bindingGeneration:account.bindingGeneration} : null;
523
+ };
524
+ const protocol = new PaymentsContextProtocol(UPSTREAM_KEY, UPSTREAM ?? 'https://gateway-mock.invalid', async request => {
525
+ if (UPSTREAM) {
526
+ const response = await fetch(`${UPSTREAM}${request.path}`, {method:'GET', redirect:'error',
527
+ signal:AbortSignal.timeout(5000), headers:{authorization:`Bearer ${UPSTREAM_KEY}`,
528
+ 'stripe-account':request.stripeAccount,'stripe-version':request.stripeVersion}});
529
+ return {status:response.status,body:await response.text()};
530
+ }
531
+ let object;
532
+ if (request.path === '/v1/balance') object = {object:'balance',livemode:false};
533
+ else if (request.path === `/v1/accounts/${request.stripeAccount}`) object = {object:'account',id:request.stripeAccount};
534
+ else {
535
+ const saved = ctx.state.objects.get(request.path.split('/').pop());
536
+ if (saved?.__account === request.stripeAccount) object = visible(saved);
537
+ }
538
+ return {status:object ? 200 : 404,body:JSON.stringify(object ?? {})};
539
+ });
540
+ try {
541
+ const fields = operation === 'issue' ? ['accountId','livemode','apiVersion'] : operation === 'pausedSubscription' ? ['contextToken','eventId','subscriptionId','apiVersion'] : ['contextToken','id','apiVersion'];
542
+ if (!ctx.body || typeof ctx.body !== 'object' || Array.isArray(ctx.body)
543
+ || Object.keys(ctx.body).some(k => !fields.includes(k)) || ctx.req.url.includes('?')) throw new Error('invalid');
544
+ const minute = Math.floor(Date.now()/60000);
545
+ ctx.state.rate ??= {};
546
+ const key = `${ctx.instanceId}:${minute}`;
547
+ ctx.state.rate[key] = (ctx.state.rate[key] ?? 0)+1;
548
+ if (ctx.state.rate[key] > RPM) return stripeError(ctx,429,'rate_limit_error','Payments request limit exceeded','rate_limit');
549
+ const owner = {id:ctx.instanceId,organizationId:`mock:${ctx.instanceId}`};
550
+ return ctx.send(200, await protocol[operation](owner,ctx.body,read),{'cache-control':'no-store'});
551
+ } catch {
552
+ return stripeError(ctx,409,'invalid_request_error','Payment context is unavailable or no longer matches','payments_context_invalid');
553
+ }
554
+ }
555
+
469
556
  async function stripeProxy(ctx) {
470
557
  const method = ctx.req.method;
471
558
  const path = ctx.path.replace(/^\/instance-gateway\/stripe/, '');
@@ -532,6 +619,12 @@ export default {
532
619
  routes: [
533
620
  { method: 'POST', path: '/payments/onboarding-link', handler: onboardingLink },
534
621
  { method: 'GET', path: '/payments/status', handler: status },
622
+ { method: 'GET', path: '/payments/payouts', handler: payouts },
623
+ { method: 'POST', path: '/payments/dashboard-link', handler: dashboardLink },
624
+ { method: 'POST', path: '/payments/context', handler: ctx => scopedRead(ctx,'issue') },
625
+ { method: 'POST', path: '/payments/context/checkout-read', handler: ctx => scopedRead(ctx,'checkout') },
626
+ { method: 'POST', path: '/payments/context/payment-link-read', handler: ctx => scopedRead(ctx,'paymentLink') },
627
+ { method: 'POST', path: '/payments/context/paused-subscription-read', handler: ctx => scopedRead(ctx,'pausedSubscription') },
535
628
  ...['GET', 'POST', 'DELETE'].map((method) => ({ method, path: PROXY, handler: stripeProxy }))
536
629
  ],
537
630
  vendorRoutes: [
@@ -0,0 +1,26 @@
1
+ import { type ModelGatewayClient } from '../http/modelGatewayClient';
2
+ import { type AgentEvent, type AgentLimits, type AgentTaskRequest, type AgentTaskResult, type AgentToolContext, type AgentToolListing, type ToolSource } from './types';
3
+ export declare const DEFAULT_AGENT_LIMITS: AgentLimits;
4
+ export interface AgentDefinition {
5
+ name: string;
6
+ instructions: string;
7
+ /** Catalog model alias. Default: the `AGENT_MODEL` setting. */
8
+ model?: string;
9
+ sources: ToolSource[];
10
+ limits?: Partial<AgentLimits>;
11
+ /** Key that seals approval continuations. Default: the `HMAC_SECRET_KEY` setting. */
12
+ continuationSecret?: string;
13
+ /** Stream model output. Default: the `FORKLAUNCH_MODEL_STREAMING` setting is `1`. */
14
+ streaming?: boolean;
15
+ client?: () => ModelGatewayClient;
16
+ }
17
+ export interface Agent {
18
+ name: string;
19
+ listTools(context: AgentToolContext): Promise<AgentToolListing>;
20
+ /** Runs or resumes a task, yielding stream events. */
21
+ stream(request: AgentTaskRequest, context: AgentToolContext): AsyncGenerator<AgentEvent>;
22
+ /** Runs or resumes a task to completion or to the next approval. */
23
+ run(request: AgentTaskRequest, context: AgentToolContext): Promise<AgentTaskResult>;
24
+ }
25
+ export declare function defineAgent(definition: AgentDefinition): Agent;
26
+ //# sourceMappingURL=agent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/agent/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,kBAAkB,EACxB,MAAM,4BAA4B,CAAC;AASpC,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EAEpB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EAErB,KAAK,UAAU,EAChB,MAAM,SAAS,CAAC;AAEjB,eAAO,MAAM,oBAAoB,EAAE,WAMlC,CAAC;AAIF,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,+DAA+D;IAC/D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,MAAM,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;IAC9B,qFAAqF;IACrF,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,qFAAqF;IACrF,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,kBAAkB,CAAC;CACnC;AAID,MAAM,WAAW,KAAK;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAChE,sDAAsD;IACtD,MAAM,CACJ,OAAO,EAAE,gBAAgB,EACzB,OAAO,EAAE,gBAAgB,GACxB,cAAc,CAAC,UAAU,CAAC,CAAC;IAC9B,oEAAoE;IACpE,GAAG,CACD,OAAO,EAAE,gBAAgB,EACzB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,eAAe,CAAC,CAAC;CAC7B;AA+BD,wBAAgB,WAAW,CAAC,UAAU,EAAE,eAAe,GAAG,KAAK,CA6b9D"}
@@ -0,0 +1,29 @@
1
+ import type { GatewayChatMessage } from '../http/modelGatewayClient';
2
+ export interface PendingToolCall {
3
+ id: string;
4
+ name: string;
5
+ arguments: string;
6
+ }
7
+ /** Everything needed to resume a run after the user decides on a tool call. */
8
+ export interface Continuation {
9
+ v: 1;
10
+ userId: string;
11
+ expiresAt: number;
12
+ steps: number;
13
+ messages: GatewayChatMessage[];
14
+ /** The call awaiting approval first, then any later calls of the same model turn. */
15
+ pending: PendingToolCall[];
16
+ toolCalls: {
17
+ id: string;
18
+ name: string;
19
+ ok: boolean;
20
+ }[];
21
+ }
22
+ export declare const CONTINUATION_TTL_MS: number;
23
+ /**
24
+ * Seals a continuation with AES-256-GCM: tool results inside stay confidential,
25
+ * and any change makes it unreadable. Nothing is stored on the server.
26
+ */
27
+ export declare function sealContinuation(value: Continuation, secret: string): string;
28
+ export declare function openContinuation(token: string, secret: string, userId: string): Continuation | null;
29
+ //# sourceMappingURL=continuation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"continuation.d.ts","sourceRoot":"","sources":["../../src/agent/continuation.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAErE,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,+EAA+E;AAC/E,MAAM,WAAW,YAAY;IAC3B,CAAC,EAAE,CAAC,CAAC;IACL,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,kBAAkB,EAAE,CAAC;IAC/B,qFAAqF;IACrF,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,SAAS,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,OAAO,CAAA;KAAE,EAAE,CAAC;CACxD;AAGD,eAAO,MAAM,mBAAmB,QAAc,CAAC;AAO/C;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAa5E;AAED,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GACb,YAAY,GAAG,IAAI,CA0BrB"}
@@ -0,0 +1,8 @@
1
+ export { defineAgent, DEFAULT_AGENT_LIMITS } from './agent';
2
+ export type { Agent, AgentDefinition } from './agent';
3
+ export { openContinuation, sealContinuation } from './continuation';
4
+ export type { Continuation, PendingToolCall } from './continuation';
5
+ export { mcpServer, serviceTools } from './sources';
6
+ export { localTools, requiresApproval, toJsonSchema, toolFactory, toolNameSegment, TOOL_NAME } from './tools';
7
+ export * from './types';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agent/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC5D,YAAY,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACpE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,eAAe,EACf,SAAS,EACV,MAAM,SAAS,CAAC;AACjB,cAAc,SAAS,CAAC"}