@forklaunch/core 3.3.0 → 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.
- package/bin/gateway-mock/routes/payments.mjs +47 -0
- package/lib/agent/agent.d.ts +26 -0
- package/lib/agent/agent.d.ts.map +1 -0
- package/lib/agent/continuation.d.ts +29 -0
- package/lib/agent/continuation.d.ts.map +1 -0
- package/lib/agent/index.d.ts +8 -0
- package/lib/agent/index.d.ts.map +1 -0
- package/lib/agent/index.js +1049 -0
- package/lib/agent/index.js.map +1 -0
- package/lib/agent/index.mjs +1005 -0
- package/lib/agent/index.mjs.map +1 -0
- package/lib/agent/sources.d.ts +27 -0
- package/lib/agent/sources.d.ts.map +1 -0
- package/lib/agent/tools.d.ts +39 -0
- package/lib/agent/tools.d.ts.map +1 -0
- package/lib/agent/types.d.ts +130 -0
- package/lib/agent/types.d.ts.map +1 -0
- package/lib/http/index.d.ts +1 -0
- package/lib/http/index.d.ts.map +1 -1
- package/lib/http/index.js +203 -38
- package/lib/http/index.js.map +1 -1
- package/lib/http/index.mjs +202 -38
- package/lib/http/index.mjs.map +1 -1
- package/lib/http/localModelGatewayClient.d.ts +27 -0
- package/lib/http/localModelGatewayClient.d.ts.map +1 -0
- package/lib/http/modelGatewayClient.d.ts.map +1 -1
- package/lib/http/modelStream.d.ts +4 -0
- package/lib/http/modelStream.d.ts.map +1 -0
- package/lib/http/paymentsClient.d.ts +55 -1
- package/lib/http/paymentsClient.d.ts.map +1 -1
- package/lib/http/previewModelGatewayClient.d.ts +5 -1
- package/lib/http/previewModelGatewayClient.d.ts.map +1 -1
- package/lib/persistence/compliantField.d.ts.map +1 -1
- package/lib/persistence/index.js +6 -1
- package/lib/persistence/index.js.map +1 -1
- package/lib/persistence/index.mjs +6 -1
- package/lib/persistence/index.mjs.map +1 -1
- package/package.json +9 -2
|
@@ -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
|
*
|
|
@@ -468,6 +472,47 @@ function status(ctx) {
|
|
|
468
472
|
});
|
|
469
473
|
}
|
|
470
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
|
+
|
|
471
516
|
// Dedicated context routes never widen STRIPE_ALLOWLIST. Synthetic mode is
|
|
472
517
|
// test-only; configured upstream verifies its own actual account and mode.
|
|
473
518
|
async function scopedRead(ctx, operation) {
|
|
@@ -574,6 +619,8 @@ export default {
|
|
|
574
619
|
routes: [
|
|
575
620
|
{ method: 'POST', path: '/payments/onboarding-link', handler: onboardingLink },
|
|
576
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 },
|
|
577
624
|
{ method: 'POST', path: '/payments/context', handler: ctx => scopedRead(ctx,'issue') },
|
|
578
625
|
{ method: 'POST', path: '/payments/context/checkout-read', handler: ctx => scopedRead(ctx,'checkout') },
|
|
579
626
|
{ method: 'POST', path: '/payments/context/payment-link-read', handler: ctx => scopedRead(ctx,'paymentLink') },
|
|
@@ -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"}
|