@percena/weft 0.4.0-next.7 → 0.4.0-next.9
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/dist/chat.cjs +2 -2
- package/dist/chat.d.cts +0 -167
- package/dist/chat.d.ts +0 -167
- package/dist/chat.js +2 -2
- package/dist/index.cjs +23 -17
- package/dist/index.d.cts +51 -1774
- package/dist/index.d.ts +51 -1774
- package/dist/index.js +23 -17
- package/dist/providers-flitro.cjs +35 -29
- package/dist/providers-flitro.d.cts +51 -49
- package/dist/providers-flitro.d.ts +51 -49
- package/dist/providers-flitro.js +31 -25
- package/package.json +3 -3
|
@@ -3119,13 +3119,13 @@ interface TimelineStream {
|
|
|
3119
3119
|
}
|
|
3120
3120
|
|
|
3121
3121
|
/**
|
|
3122
|
-
*
|
|
3122
|
+
* WeftHttpClient
|
|
3123
3123
|
*
|
|
3124
|
-
* Typed HTTP client for the
|
|
3125
|
-
* All methods map 1-to-1 with
|
|
3124
|
+
* Typed HTTP client for the Weft Server REST API.
|
|
3125
|
+
* All methods map 1-to-1 with the server's HTTP endpoints.
|
|
3126
3126
|
*/
|
|
3127
|
-
interface
|
|
3128
|
-
/** Base URL of the
|
|
3127
|
+
interface WeftHttpClientOptions {
|
|
3128
|
+
/** Base URL of the Weft server, e.g. http://localhost:8080 */
|
|
3129
3129
|
baseUrl: string;
|
|
3130
3130
|
/** Optional bearer token for API-key auth */
|
|
3131
3131
|
apiKey?: string;
|
|
@@ -3134,7 +3134,7 @@ interface FlitroClientOptions {
|
|
|
3134
3134
|
/** Optional timeout in milliseconds (default: 30000) */
|
|
3135
3135
|
timeout?: number;
|
|
3136
3136
|
/**
|
|
3137
|
-
* Scoped embed session token minted by the host backend via
|
|
3137
|
+
* Scoped embed session token minted by the host backend via
|
|
3138
3138
|
* `POST /v1/embed/sessions`. Sent as the Authorization bearer; the token
|
|
3139
3139
|
* already carries tenant and session scope, so apiKey/tenantId are not
|
|
3140
3140
|
* needed (and are ignored) when it is set.
|
|
@@ -3147,7 +3147,7 @@ interface FlitroClientOptions {
|
|
|
3147
3147
|
*/
|
|
3148
3148
|
onTokenExpired?: () => Promise<string | undefined> | string | undefined;
|
|
3149
3149
|
}
|
|
3150
|
-
interface
|
|
3150
|
+
interface WeftSession {
|
|
3151
3151
|
session_id: string;
|
|
3152
3152
|
tenant_id: string;
|
|
3153
3153
|
app_id?: string;
|
|
@@ -3167,7 +3167,7 @@ interface FlitroSession {
|
|
|
3167
3167
|
created_at: string;
|
|
3168
3168
|
updated_at: string;
|
|
3169
3169
|
}
|
|
3170
|
-
interface
|
|
3170
|
+
interface WeftRun {
|
|
3171
3171
|
run_id: string;
|
|
3172
3172
|
session_id: string;
|
|
3173
3173
|
tenant_id?: string;
|
|
@@ -3193,7 +3193,7 @@ interface FlitroRun {
|
|
|
3193
3193
|
created_at: string;
|
|
3194
3194
|
updated_at: string;
|
|
3195
3195
|
}
|
|
3196
|
-
interface
|
|
3196
|
+
interface WeftCapabilityReport {
|
|
3197
3197
|
provider: string;
|
|
3198
3198
|
runtimeKind: string;
|
|
3199
3199
|
selected: string;
|
|
@@ -3214,25 +3214,25 @@ interface FlitroCapabilityReport {
|
|
|
3214
3214
|
automationCapabilities: Record<string, unknown>;
|
|
3215
3215
|
hostToolCapabilities: Record<string, unknown>;
|
|
3216
3216
|
}
|
|
3217
|
-
interface
|
|
3217
|
+
interface WeftPatchSessionOptions {
|
|
3218
3218
|
title?: string;
|
|
3219
3219
|
status?: string;
|
|
3220
3220
|
labels?: string[];
|
|
3221
3221
|
flagged?: boolean;
|
|
3222
3222
|
topic?: string;
|
|
3223
3223
|
}
|
|
3224
|
-
interface
|
|
3224
|
+
interface WeftModelInfo {
|
|
3225
3225
|
id: string;
|
|
3226
3226
|
provider: string;
|
|
3227
3227
|
display_name?: string;
|
|
3228
3228
|
aliases?: string[];
|
|
3229
3229
|
capabilities: Record<string, unknown>;
|
|
3230
3230
|
}
|
|
3231
|
-
interface
|
|
3232
|
-
models:
|
|
3231
|
+
interface WeftModelListResult {
|
|
3232
|
+
models: WeftModelInfo[];
|
|
3233
3233
|
default?: string;
|
|
3234
3234
|
}
|
|
3235
|
-
interface
|
|
3235
|
+
interface WeftTimelineItem {
|
|
3236
3236
|
sessionId: string;
|
|
3237
3237
|
provider: string;
|
|
3238
3238
|
seq: number;
|
|
@@ -3240,28 +3240,30 @@ interface FlitroTimelineItem {
|
|
|
3240
3240
|
timestamp: number;
|
|
3241
3241
|
item: Record<string, unknown>;
|
|
3242
3242
|
}
|
|
3243
|
-
interface
|
|
3244
|
-
items:
|
|
3243
|
+
interface WeftTimelineFetchResult {
|
|
3244
|
+
items: WeftTimelineItem[];
|
|
3245
3245
|
nextCursor: {
|
|
3246
3246
|
epoch: string;
|
|
3247
3247
|
afterSeq: number;
|
|
3248
3248
|
};
|
|
3249
3249
|
hasGap: boolean;
|
|
3250
3250
|
}
|
|
3251
|
-
declare class
|
|
3251
|
+
declare class WeftHttpClient {
|
|
3252
3252
|
private readonly baseUrl;
|
|
3253
3253
|
private readonly timeout;
|
|
3254
3254
|
private readonly apiKey;
|
|
3255
3255
|
private readonly tenantId;
|
|
3256
3256
|
private readonly onTokenExpired?;
|
|
3257
3257
|
private token;
|
|
3258
|
-
|
|
3258
|
+
private readonly embedMode;
|
|
3259
|
+
constructor(options: WeftHttpClientOptions);
|
|
3260
|
+
private sessionPath;
|
|
3259
3261
|
/** Current Authorization bearer (scoped token wins over apiKey). */
|
|
3260
3262
|
getBearerToken(): string;
|
|
3261
3263
|
/** Replace the scoped token (e.g. after a host-backend refresh). */
|
|
3262
3264
|
setToken(token: string): void;
|
|
3263
3265
|
private buildHeaders;
|
|
3264
|
-
preflight(): Promise<
|
|
3266
|
+
preflight(): Promise<WeftCapabilityReport>;
|
|
3265
3267
|
health(): Promise<{
|
|
3266
3268
|
status: string;
|
|
3267
3269
|
}>;
|
|
@@ -3270,8 +3272,8 @@ declare class FlitroHttpClient {
|
|
|
3270
3272
|
model?: string;
|
|
3271
3273
|
skillNames?: string[];
|
|
3272
3274
|
mcpServerNames?: string[];
|
|
3273
|
-
}): Promise<
|
|
3274
|
-
getSession(sessionId: string): Promise<
|
|
3275
|
+
}): Promise<WeftSession>;
|
|
3276
|
+
getSession(sessionId: string): Promise<WeftSession>;
|
|
3275
3277
|
sendMessage(sessionId: string, message: string, options?: {
|
|
3276
3278
|
model?: string;
|
|
3277
3279
|
skillNames?: string[];
|
|
@@ -3285,7 +3287,7 @@ declare class FlitroHttpClient {
|
|
|
3285
3287
|
maxTokens?: number;
|
|
3286
3288
|
maxWallTimeSec?: number;
|
|
3287
3289
|
};
|
|
3288
|
-
}): Promise<
|
|
3290
|
+
}): Promise<WeftRun>;
|
|
3289
3291
|
cancelRun(runId: string): Promise<{
|
|
3290
3292
|
status: string;
|
|
3291
3293
|
}>;
|
|
@@ -3301,9 +3303,9 @@ declare class FlitroHttpClient {
|
|
|
3301
3303
|
type: string;
|
|
3302
3304
|
requestId: string;
|
|
3303
3305
|
}>;
|
|
3304
|
-
patchSession(sessionId: string, patch:
|
|
3305
|
-
listModels(): Promise<
|
|
3306
|
-
fetchTimeline(sessionId: string, afterSeq?: number, limit?: number): Promise<
|
|
3306
|
+
patchSession(sessionId: string, patch: WeftPatchSessionOptions): Promise<WeftSession>;
|
|
3307
|
+
listModels(): Promise<WeftModelListResult>;
|
|
3308
|
+
fetchTimeline(sessionId: string, afterSeq?: number, limit?: number): Promise<WeftTimelineFetchResult>;
|
|
3307
3309
|
/** Returns the SSE stream URL for a session's canonical timeline. */
|
|
3308
3310
|
sessionTimelineUrl(sessionId: string): string;
|
|
3309
3311
|
private get;
|
|
@@ -3313,13 +3315,13 @@ declare class FlitroHttpClient {
|
|
|
3313
3315
|
}
|
|
3314
3316
|
|
|
3315
3317
|
/**
|
|
3316
|
-
*
|
|
3318
|
+
* WeftSseTimelineStream
|
|
3317
3319
|
*
|
|
3318
|
-
* Consumes
|
|
3319
|
-
* a Weft TimelineStream.
|
|
3320
|
+
* Consumes the session-scoped SSE timeline endpoint and exposes it as
|
|
3321
|
+
* a Weft TimelineStream. Handles reconnection with cursor tracking.
|
|
3320
3322
|
*/
|
|
3321
3323
|
|
|
3322
|
-
interface
|
|
3324
|
+
interface WeftSseTimelineStreamOptions {
|
|
3323
3325
|
/** Full URL to the session timeline SSE endpoint */
|
|
3324
3326
|
url: string;
|
|
3325
3327
|
/** Optional bearer token */
|
|
@@ -3344,7 +3346,7 @@ interface FlitroSseTimelineStreamOptions {
|
|
|
3344
3346
|
*/
|
|
3345
3347
|
onTokenExpired?: () => Promise<string | undefined> | string | undefined;
|
|
3346
3348
|
}
|
|
3347
|
-
declare class
|
|
3349
|
+
declare class WeftSseTimelineStream implements TimelineStream {
|
|
3348
3350
|
private listeners;
|
|
3349
3351
|
private eventSource;
|
|
3350
3352
|
private disposed;
|
|
@@ -3352,7 +3354,7 @@ declare class FlitroSseTimelineStream implements TimelineStream {
|
|
|
3352
3354
|
private afterSeq;
|
|
3353
3355
|
private readonly getBearerToken?;
|
|
3354
3356
|
private readonly options;
|
|
3355
|
-
constructor(options:
|
|
3357
|
+
constructor(options: WeftSseTimelineStreamOptions);
|
|
3356
3358
|
connect(onEvent: (event: TimelineEnvelope) => void, onError?: (error: Error) => void, onClose?: () => void): void;
|
|
3357
3359
|
disconnect(): void;
|
|
3358
3360
|
isConnected(): boolean;
|
|
@@ -3365,7 +3367,7 @@ declare class FlitroSseTimelineStream implements TimelineStream {
|
|
|
3365
3367
|
* In Node.js environments (Node 18+) EventSource may not be available globally.
|
|
3366
3368
|
* This minimal polyfill wraps the fetch API for SSE consumption.
|
|
3367
3369
|
*/
|
|
3368
|
-
declare class
|
|
3370
|
+
declare class WeftFetchSseTimelineStream implements TimelineStream {
|
|
3369
3371
|
private listeners;
|
|
3370
3372
|
private abortController;
|
|
3371
3373
|
private connected;
|
|
@@ -3376,7 +3378,7 @@ declare class FlitroFetchSseTimelineStream implements TimelineStream {
|
|
|
3376
3378
|
private readonly getBearerToken?;
|
|
3377
3379
|
private readonly onTokenExpired?;
|
|
3378
3380
|
private readonly options;
|
|
3379
|
-
constructor(options:
|
|
3381
|
+
constructor(options: WeftSseTimelineStreamOptions);
|
|
3380
3382
|
connect(onEvent: (event: TimelineEnvelope) => void, onError?: (error: Error) => void, onClose?: () => void): void;
|
|
3381
3383
|
disconnect(): void;
|
|
3382
3384
|
isConnected(): boolean;
|
|
@@ -3387,16 +3389,16 @@ declare class FlitroFetchSseTimelineStream implements TimelineStream {
|
|
|
3387
3389
|
private emitError;
|
|
3388
3390
|
}
|
|
3389
3391
|
/**
|
|
3390
|
-
* Create an SSE stream for the
|
|
3392
|
+
* Create an SSE stream for the timeline endpoint.
|
|
3391
3393
|
* Always uses the fetch-based implementation so credentials are sent via
|
|
3392
3394
|
* Authorization header rather than URL query parameters.
|
|
3393
3395
|
*/
|
|
3394
|
-
declare function
|
|
3396
|
+
declare function createTimelineStream(options: WeftSseTimelineStreamOptions): TimelineStream;
|
|
3395
3397
|
|
|
3396
3398
|
/**
|
|
3397
3399
|
* WeftClient — the public L2 ("headless") contract.
|
|
3398
3400
|
*
|
|
3399
|
-
* A thin namespaced facade over
|
|
3401
|
+
* A thin namespaced facade over WeftHttpClient + the SSE timeline stream:
|
|
3400
3402
|
*
|
|
3401
3403
|
* ```ts
|
|
3402
3404
|
* const client = new WeftClient({ server, token })
|
|
@@ -3424,21 +3426,21 @@ interface WeftClientOptions {
|
|
|
3424
3426
|
* Called on HTTP 401 with a scoped token. Return a fresh token (e.g. by
|
|
3425
3427
|
* re-asking your backend) to retry once; return undefined to surface the 401.
|
|
3426
3428
|
*/
|
|
3427
|
-
onTokenExpired?:
|
|
3429
|
+
onTokenExpired?: WeftHttpClientOptions['onTokenExpired'];
|
|
3428
3430
|
}
|
|
3429
3431
|
interface TimelineSubscription extends TimelineStream, AsyncIterable<TimelineEnvelope> {
|
|
3430
3432
|
}
|
|
3431
3433
|
declare class WeftClient {
|
|
3432
3434
|
/** The underlying 1:1 HTTP client, for endpoints not wrapped below. */
|
|
3433
|
-
readonly http:
|
|
3435
|
+
readonly http: WeftHttpClient;
|
|
3434
3436
|
private readonly options;
|
|
3435
3437
|
constructor(options: WeftClientOptions);
|
|
3436
3438
|
/** Replace the scoped token (e.g. after a backend-driven refresh). */
|
|
3437
3439
|
setToken(token: string): void;
|
|
3438
3440
|
readonly sessions: {
|
|
3439
|
-
create: (options?: Parameters<
|
|
3440
|
-
get: (sessionId: string) => Promise<
|
|
3441
|
-
patch: (sessionId: string, patch:
|
|
3441
|
+
create: (options?: Parameters<WeftHttpClient["createSession"]>[0]) => Promise<WeftSession>;
|
|
3442
|
+
get: (sessionId: string) => Promise<WeftSession>;
|
|
3443
|
+
patch: (sessionId: string, patch: WeftPatchSessionOptions) => Promise<WeftSession>;
|
|
3442
3444
|
respondToPermission: (sessionId: string, requestId: string, allowed: boolean, options?: {
|
|
3443
3445
|
remember?: boolean;
|
|
3444
3446
|
text?: string;
|
|
@@ -3452,7 +3454,7 @@ declare class WeftClient {
|
|
|
3452
3454
|
readonly runs: {
|
|
3453
3455
|
create: (sessionId: string, options: {
|
|
3454
3456
|
message: string;
|
|
3455
|
-
} & NonNullable<Parameters<
|
|
3457
|
+
} & NonNullable<Parameters<WeftHttpClient["sendMessage"]>[2]>) => Promise<WeftRun>;
|
|
3456
3458
|
cancel: (runId: string) => Promise<{
|
|
3457
3459
|
status: string;
|
|
3458
3460
|
}>;
|
|
@@ -3461,17 +3463,17 @@ declare class WeftClient {
|
|
|
3461
3463
|
}>;
|
|
3462
3464
|
};
|
|
3463
3465
|
readonly timeline: {
|
|
3464
|
-
fetch: (sessionId: string, afterSeq?: number, limit?: number) => Promise<
|
|
3466
|
+
fetch: (sessionId: string, afterSeq?: number, limit?: number) => Promise<WeftTimelineFetchResult>;
|
|
3465
3467
|
/**
|
|
3466
3468
|
* Subscribe to the session's SSE timeline. Reconnects automatically with
|
|
3467
3469
|
* cursor tracking; usable both callback-style (`connect`) and as an
|
|
3468
3470
|
* async iterable (`for await`).
|
|
3469
3471
|
*/
|
|
3470
|
-
subscribe: (sessionId: string, options?: Partial<Omit<
|
|
3472
|
+
subscribe: (sessionId: string, options?: Partial<Omit<WeftSseTimelineStreamOptions, "url">>) => TimelineSubscription;
|
|
3471
3473
|
};
|
|
3472
3474
|
}
|
|
3473
3475
|
|
|
3474
|
-
export { type
|
|
3476
|
+
export { type TimelineEnvelope, type TimelineStream, type TimelineSubscription, type WeftCapabilityReport, WeftClient, type WeftClientOptions, WeftFetchSseTimelineStream, WeftHttpClient, type WeftHttpClientOptions, type WeftModelInfo, type WeftModelListResult, type WeftPatchSessionOptions, type WeftRun, type WeftSession, WeftSseTimelineStream, type WeftSseTimelineStreamOptions, type WeftTimelineFetchResult, type WeftTimelineItem, createTimelineStream };
|
|
3475
3477
|
|
|
3476
3478
|
// ── inlined from @weft/provider-flitro ──
|
|
3477
3479
|
// -- @weft/provider-flitro/index.d.ts --
|
|
@@ -3496,7 +3498,7 @@ interface FlitroProviderRuntimeDriver {
|
|
|
3496
3498
|
dispose?(): Promise<void>;
|
|
3497
3499
|
}
|
|
3498
3500
|
interface CreateFlitroDriverOptions {
|
|
3499
|
-
client:
|
|
3501
|
+
client: WeftHttpClient;
|
|
3500
3502
|
sessionId: string;
|
|
3501
3503
|
/** LLM model override sent to Flitro */
|
|
3502
3504
|
model?: string;
|
|
@@ -3537,7 +3539,7 @@ interface FlitroCapabilityProbeResult {
|
|
|
3537
3539
|
* process (the Go agentd binary) that the TypeScript provider communicates
|
|
3538
3540
|
* with over HTTP.
|
|
3539
3541
|
*/
|
|
3540
|
-
declare function probeFlitroCapabilities(client:
|
|
3542
|
+
declare function probeFlitroCapabilities(client: WeftHttpClient): Promise<FlitroCapabilityProbeResult>;
|
|
3541
3543
|
|
|
3542
3544
|
/**
|
|
3543
3545
|
* @weft/provider-flitro
|
|
@@ -3570,7 +3572,7 @@ interface CreateFlitroRuntimeCapabilityReportOptions {
|
|
|
3570
3572
|
declare function createFlitroRuntimeCapabilityReport(options: CreateFlitroRuntimeCapabilityReportOptions): RuntimeCapabilityReport;
|
|
3571
3573
|
interface CreateFlitroProviderRuntimeOptions extends CreateFlitroRuntimeCapabilityReportOptions {
|
|
3572
3574
|
/** Flitro server connection options */
|
|
3573
|
-
server:
|
|
3575
|
+
server: WeftHttpClientOptions;
|
|
3574
3576
|
/** Session ID — if omitted a new session is created on first sendMessage */
|
|
3575
3577
|
sessionId?: string;
|
|
3576
3578
|
/** Epoch string for the timeline (default: derived from sessionId) */
|
|
@@ -3630,7 +3632,7 @@ interface CreateFlitroEmbedRuntimeOptions {
|
|
|
3630
3632
|
declare function createFlitroEmbedRuntime(options: CreateFlitroEmbedRuntimeOptions): AgentRuntime;
|
|
3631
3633
|
interface CreateFlitroRuntimeOptions {
|
|
3632
3634
|
/** Flitro server connection options */
|
|
3633
|
-
server:
|
|
3635
|
+
server: WeftHttpClientOptions;
|
|
3634
3636
|
sessionId?: string;
|
|
3635
3637
|
epoch?: string;
|
|
3636
3638
|
now?: () => number;
|
|
@@ -3119,13 +3119,13 @@ interface TimelineStream {
|
|
|
3119
3119
|
}
|
|
3120
3120
|
|
|
3121
3121
|
/**
|
|
3122
|
-
*
|
|
3122
|
+
* WeftHttpClient
|
|
3123
3123
|
*
|
|
3124
|
-
* Typed HTTP client for the
|
|
3125
|
-
* All methods map 1-to-1 with
|
|
3124
|
+
* Typed HTTP client for the Weft Server REST API.
|
|
3125
|
+
* All methods map 1-to-1 with the server's HTTP endpoints.
|
|
3126
3126
|
*/
|
|
3127
|
-
interface
|
|
3128
|
-
/** Base URL of the
|
|
3127
|
+
interface WeftHttpClientOptions {
|
|
3128
|
+
/** Base URL of the Weft server, e.g. http://localhost:8080 */
|
|
3129
3129
|
baseUrl: string;
|
|
3130
3130
|
/** Optional bearer token for API-key auth */
|
|
3131
3131
|
apiKey?: string;
|
|
@@ -3134,7 +3134,7 @@ interface FlitroClientOptions {
|
|
|
3134
3134
|
/** Optional timeout in milliseconds (default: 30000) */
|
|
3135
3135
|
timeout?: number;
|
|
3136
3136
|
/**
|
|
3137
|
-
* Scoped embed session token minted by the host backend via
|
|
3137
|
+
* Scoped embed session token minted by the host backend via
|
|
3138
3138
|
* `POST /v1/embed/sessions`. Sent as the Authorization bearer; the token
|
|
3139
3139
|
* already carries tenant and session scope, so apiKey/tenantId are not
|
|
3140
3140
|
* needed (and are ignored) when it is set.
|
|
@@ -3147,7 +3147,7 @@ interface FlitroClientOptions {
|
|
|
3147
3147
|
*/
|
|
3148
3148
|
onTokenExpired?: () => Promise<string | undefined> | string | undefined;
|
|
3149
3149
|
}
|
|
3150
|
-
interface
|
|
3150
|
+
interface WeftSession {
|
|
3151
3151
|
session_id: string;
|
|
3152
3152
|
tenant_id: string;
|
|
3153
3153
|
app_id?: string;
|
|
@@ -3167,7 +3167,7 @@ interface FlitroSession {
|
|
|
3167
3167
|
created_at: string;
|
|
3168
3168
|
updated_at: string;
|
|
3169
3169
|
}
|
|
3170
|
-
interface
|
|
3170
|
+
interface WeftRun {
|
|
3171
3171
|
run_id: string;
|
|
3172
3172
|
session_id: string;
|
|
3173
3173
|
tenant_id?: string;
|
|
@@ -3193,7 +3193,7 @@ interface FlitroRun {
|
|
|
3193
3193
|
created_at: string;
|
|
3194
3194
|
updated_at: string;
|
|
3195
3195
|
}
|
|
3196
|
-
interface
|
|
3196
|
+
interface WeftCapabilityReport {
|
|
3197
3197
|
provider: string;
|
|
3198
3198
|
runtimeKind: string;
|
|
3199
3199
|
selected: string;
|
|
@@ -3214,25 +3214,25 @@ interface FlitroCapabilityReport {
|
|
|
3214
3214
|
automationCapabilities: Record<string, unknown>;
|
|
3215
3215
|
hostToolCapabilities: Record<string, unknown>;
|
|
3216
3216
|
}
|
|
3217
|
-
interface
|
|
3217
|
+
interface WeftPatchSessionOptions {
|
|
3218
3218
|
title?: string;
|
|
3219
3219
|
status?: string;
|
|
3220
3220
|
labels?: string[];
|
|
3221
3221
|
flagged?: boolean;
|
|
3222
3222
|
topic?: string;
|
|
3223
3223
|
}
|
|
3224
|
-
interface
|
|
3224
|
+
interface WeftModelInfo {
|
|
3225
3225
|
id: string;
|
|
3226
3226
|
provider: string;
|
|
3227
3227
|
display_name?: string;
|
|
3228
3228
|
aliases?: string[];
|
|
3229
3229
|
capabilities: Record<string, unknown>;
|
|
3230
3230
|
}
|
|
3231
|
-
interface
|
|
3232
|
-
models:
|
|
3231
|
+
interface WeftModelListResult {
|
|
3232
|
+
models: WeftModelInfo[];
|
|
3233
3233
|
default?: string;
|
|
3234
3234
|
}
|
|
3235
|
-
interface
|
|
3235
|
+
interface WeftTimelineItem {
|
|
3236
3236
|
sessionId: string;
|
|
3237
3237
|
provider: string;
|
|
3238
3238
|
seq: number;
|
|
@@ -3240,28 +3240,30 @@ interface FlitroTimelineItem {
|
|
|
3240
3240
|
timestamp: number;
|
|
3241
3241
|
item: Record<string, unknown>;
|
|
3242
3242
|
}
|
|
3243
|
-
interface
|
|
3244
|
-
items:
|
|
3243
|
+
interface WeftTimelineFetchResult {
|
|
3244
|
+
items: WeftTimelineItem[];
|
|
3245
3245
|
nextCursor: {
|
|
3246
3246
|
epoch: string;
|
|
3247
3247
|
afterSeq: number;
|
|
3248
3248
|
};
|
|
3249
3249
|
hasGap: boolean;
|
|
3250
3250
|
}
|
|
3251
|
-
declare class
|
|
3251
|
+
declare class WeftHttpClient {
|
|
3252
3252
|
private readonly baseUrl;
|
|
3253
3253
|
private readonly timeout;
|
|
3254
3254
|
private readonly apiKey;
|
|
3255
3255
|
private readonly tenantId;
|
|
3256
3256
|
private readonly onTokenExpired?;
|
|
3257
3257
|
private token;
|
|
3258
|
-
|
|
3258
|
+
private readonly embedMode;
|
|
3259
|
+
constructor(options: WeftHttpClientOptions);
|
|
3260
|
+
private sessionPath;
|
|
3259
3261
|
/** Current Authorization bearer (scoped token wins over apiKey). */
|
|
3260
3262
|
getBearerToken(): string;
|
|
3261
3263
|
/** Replace the scoped token (e.g. after a host-backend refresh). */
|
|
3262
3264
|
setToken(token: string): void;
|
|
3263
3265
|
private buildHeaders;
|
|
3264
|
-
preflight(): Promise<
|
|
3266
|
+
preflight(): Promise<WeftCapabilityReport>;
|
|
3265
3267
|
health(): Promise<{
|
|
3266
3268
|
status: string;
|
|
3267
3269
|
}>;
|
|
@@ -3270,8 +3272,8 @@ declare class FlitroHttpClient {
|
|
|
3270
3272
|
model?: string;
|
|
3271
3273
|
skillNames?: string[];
|
|
3272
3274
|
mcpServerNames?: string[];
|
|
3273
|
-
}): Promise<
|
|
3274
|
-
getSession(sessionId: string): Promise<
|
|
3275
|
+
}): Promise<WeftSession>;
|
|
3276
|
+
getSession(sessionId: string): Promise<WeftSession>;
|
|
3275
3277
|
sendMessage(sessionId: string, message: string, options?: {
|
|
3276
3278
|
model?: string;
|
|
3277
3279
|
skillNames?: string[];
|
|
@@ -3285,7 +3287,7 @@ declare class FlitroHttpClient {
|
|
|
3285
3287
|
maxTokens?: number;
|
|
3286
3288
|
maxWallTimeSec?: number;
|
|
3287
3289
|
};
|
|
3288
|
-
}): Promise<
|
|
3290
|
+
}): Promise<WeftRun>;
|
|
3289
3291
|
cancelRun(runId: string): Promise<{
|
|
3290
3292
|
status: string;
|
|
3291
3293
|
}>;
|
|
@@ -3301,9 +3303,9 @@ declare class FlitroHttpClient {
|
|
|
3301
3303
|
type: string;
|
|
3302
3304
|
requestId: string;
|
|
3303
3305
|
}>;
|
|
3304
|
-
patchSession(sessionId: string, patch:
|
|
3305
|
-
listModels(): Promise<
|
|
3306
|
-
fetchTimeline(sessionId: string, afterSeq?: number, limit?: number): Promise<
|
|
3306
|
+
patchSession(sessionId: string, patch: WeftPatchSessionOptions): Promise<WeftSession>;
|
|
3307
|
+
listModels(): Promise<WeftModelListResult>;
|
|
3308
|
+
fetchTimeline(sessionId: string, afterSeq?: number, limit?: number): Promise<WeftTimelineFetchResult>;
|
|
3307
3309
|
/** Returns the SSE stream URL for a session's canonical timeline. */
|
|
3308
3310
|
sessionTimelineUrl(sessionId: string): string;
|
|
3309
3311
|
private get;
|
|
@@ -3313,13 +3315,13 @@ declare class FlitroHttpClient {
|
|
|
3313
3315
|
}
|
|
3314
3316
|
|
|
3315
3317
|
/**
|
|
3316
|
-
*
|
|
3318
|
+
* WeftSseTimelineStream
|
|
3317
3319
|
*
|
|
3318
|
-
* Consumes
|
|
3319
|
-
* a Weft TimelineStream.
|
|
3320
|
+
* Consumes the session-scoped SSE timeline endpoint and exposes it as
|
|
3321
|
+
* a Weft TimelineStream. Handles reconnection with cursor tracking.
|
|
3320
3322
|
*/
|
|
3321
3323
|
|
|
3322
|
-
interface
|
|
3324
|
+
interface WeftSseTimelineStreamOptions {
|
|
3323
3325
|
/** Full URL to the session timeline SSE endpoint */
|
|
3324
3326
|
url: string;
|
|
3325
3327
|
/** Optional bearer token */
|
|
@@ -3344,7 +3346,7 @@ interface FlitroSseTimelineStreamOptions {
|
|
|
3344
3346
|
*/
|
|
3345
3347
|
onTokenExpired?: () => Promise<string | undefined> | string | undefined;
|
|
3346
3348
|
}
|
|
3347
|
-
declare class
|
|
3349
|
+
declare class WeftSseTimelineStream implements TimelineStream {
|
|
3348
3350
|
private listeners;
|
|
3349
3351
|
private eventSource;
|
|
3350
3352
|
private disposed;
|
|
@@ -3352,7 +3354,7 @@ declare class FlitroSseTimelineStream implements TimelineStream {
|
|
|
3352
3354
|
private afterSeq;
|
|
3353
3355
|
private readonly getBearerToken?;
|
|
3354
3356
|
private readonly options;
|
|
3355
|
-
constructor(options:
|
|
3357
|
+
constructor(options: WeftSseTimelineStreamOptions);
|
|
3356
3358
|
connect(onEvent: (event: TimelineEnvelope) => void, onError?: (error: Error) => void, onClose?: () => void): void;
|
|
3357
3359
|
disconnect(): void;
|
|
3358
3360
|
isConnected(): boolean;
|
|
@@ -3365,7 +3367,7 @@ declare class FlitroSseTimelineStream implements TimelineStream {
|
|
|
3365
3367
|
* In Node.js environments (Node 18+) EventSource may not be available globally.
|
|
3366
3368
|
* This minimal polyfill wraps the fetch API for SSE consumption.
|
|
3367
3369
|
*/
|
|
3368
|
-
declare class
|
|
3370
|
+
declare class WeftFetchSseTimelineStream implements TimelineStream {
|
|
3369
3371
|
private listeners;
|
|
3370
3372
|
private abortController;
|
|
3371
3373
|
private connected;
|
|
@@ -3376,7 +3378,7 @@ declare class FlitroFetchSseTimelineStream implements TimelineStream {
|
|
|
3376
3378
|
private readonly getBearerToken?;
|
|
3377
3379
|
private readonly onTokenExpired?;
|
|
3378
3380
|
private readonly options;
|
|
3379
|
-
constructor(options:
|
|
3381
|
+
constructor(options: WeftSseTimelineStreamOptions);
|
|
3380
3382
|
connect(onEvent: (event: TimelineEnvelope) => void, onError?: (error: Error) => void, onClose?: () => void): void;
|
|
3381
3383
|
disconnect(): void;
|
|
3382
3384
|
isConnected(): boolean;
|
|
@@ -3387,16 +3389,16 @@ declare class FlitroFetchSseTimelineStream implements TimelineStream {
|
|
|
3387
3389
|
private emitError;
|
|
3388
3390
|
}
|
|
3389
3391
|
/**
|
|
3390
|
-
* Create an SSE stream for the
|
|
3392
|
+
* Create an SSE stream for the timeline endpoint.
|
|
3391
3393
|
* Always uses the fetch-based implementation so credentials are sent via
|
|
3392
3394
|
* Authorization header rather than URL query parameters.
|
|
3393
3395
|
*/
|
|
3394
|
-
declare function
|
|
3396
|
+
declare function createTimelineStream(options: WeftSseTimelineStreamOptions): TimelineStream;
|
|
3395
3397
|
|
|
3396
3398
|
/**
|
|
3397
3399
|
* WeftClient — the public L2 ("headless") contract.
|
|
3398
3400
|
*
|
|
3399
|
-
* A thin namespaced facade over
|
|
3401
|
+
* A thin namespaced facade over WeftHttpClient + the SSE timeline stream:
|
|
3400
3402
|
*
|
|
3401
3403
|
* ```ts
|
|
3402
3404
|
* const client = new WeftClient({ server, token })
|
|
@@ -3424,21 +3426,21 @@ interface WeftClientOptions {
|
|
|
3424
3426
|
* Called on HTTP 401 with a scoped token. Return a fresh token (e.g. by
|
|
3425
3427
|
* re-asking your backend) to retry once; return undefined to surface the 401.
|
|
3426
3428
|
*/
|
|
3427
|
-
onTokenExpired?:
|
|
3429
|
+
onTokenExpired?: WeftHttpClientOptions['onTokenExpired'];
|
|
3428
3430
|
}
|
|
3429
3431
|
interface TimelineSubscription extends TimelineStream, AsyncIterable<TimelineEnvelope> {
|
|
3430
3432
|
}
|
|
3431
3433
|
declare class WeftClient {
|
|
3432
3434
|
/** The underlying 1:1 HTTP client, for endpoints not wrapped below. */
|
|
3433
|
-
readonly http:
|
|
3435
|
+
readonly http: WeftHttpClient;
|
|
3434
3436
|
private readonly options;
|
|
3435
3437
|
constructor(options: WeftClientOptions);
|
|
3436
3438
|
/** Replace the scoped token (e.g. after a backend-driven refresh). */
|
|
3437
3439
|
setToken(token: string): void;
|
|
3438
3440
|
readonly sessions: {
|
|
3439
|
-
create: (options?: Parameters<
|
|
3440
|
-
get: (sessionId: string) => Promise<
|
|
3441
|
-
patch: (sessionId: string, patch:
|
|
3441
|
+
create: (options?: Parameters<WeftHttpClient["createSession"]>[0]) => Promise<WeftSession>;
|
|
3442
|
+
get: (sessionId: string) => Promise<WeftSession>;
|
|
3443
|
+
patch: (sessionId: string, patch: WeftPatchSessionOptions) => Promise<WeftSession>;
|
|
3442
3444
|
respondToPermission: (sessionId: string, requestId: string, allowed: boolean, options?: {
|
|
3443
3445
|
remember?: boolean;
|
|
3444
3446
|
text?: string;
|
|
@@ -3452,7 +3454,7 @@ declare class WeftClient {
|
|
|
3452
3454
|
readonly runs: {
|
|
3453
3455
|
create: (sessionId: string, options: {
|
|
3454
3456
|
message: string;
|
|
3455
|
-
} & NonNullable<Parameters<
|
|
3457
|
+
} & NonNullable<Parameters<WeftHttpClient["sendMessage"]>[2]>) => Promise<WeftRun>;
|
|
3456
3458
|
cancel: (runId: string) => Promise<{
|
|
3457
3459
|
status: string;
|
|
3458
3460
|
}>;
|
|
@@ -3461,17 +3463,17 @@ declare class WeftClient {
|
|
|
3461
3463
|
}>;
|
|
3462
3464
|
};
|
|
3463
3465
|
readonly timeline: {
|
|
3464
|
-
fetch: (sessionId: string, afterSeq?: number, limit?: number) => Promise<
|
|
3466
|
+
fetch: (sessionId: string, afterSeq?: number, limit?: number) => Promise<WeftTimelineFetchResult>;
|
|
3465
3467
|
/**
|
|
3466
3468
|
* Subscribe to the session's SSE timeline. Reconnects automatically with
|
|
3467
3469
|
* cursor tracking; usable both callback-style (`connect`) and as an
|
|
3468
3470
|
* async iterable (`for await`).
|
|
3469
3471
|
*/
|
|
3470
|
-
subscribe: (sessionId: string, options?: Partial<Omit<
|
|
3472
|
+
subscribe: (sessionId: string, options?: Partial<Omit<WeftSseTimelineStreamOptions, "url">>) => TimelineSubscription;
|
|
3471
3473
|
};
|
|
3472
3474
|
}
|
|
3473
3475
|
|
|
3474
|
-
export { type
|
|
3476
|
+
export { type TimelineEnvelope, type TimelineStream, type TimelineSubscription, type WeftCapabilityReport, WeftClient, type WeftClientOptions, WeftFetchSseTimelineStream, WeftHttpClient, type WeftHttpClientOptions, type WeftModelInfo, type WeftModelListResult, type WeftPatchSessionOptions, type WeftRun, type WeftSession, WeftSseTimelineStream, type WeftSseTimelineStreamOptions, type WeftTimelineFetchResult, type WeftTimelineItem, createTimelineStream };
|
|
3475
3477
|
|
|
3476
3478
|
// ── inlined from @weft/provider-flitro ──
|
|
3477
3479
|
// -- @weft/provider-flitro/index.d.ts --
|
|
@@ -3496,7 +3498,7 @@ interface FlitroProviderRuntimeDriver {
|
|
|
3496
3498
|
dispose?(): Promise<void>;
|
|
3497
3499
|
}
|
|
3498
3500
|
interface CreateFlitroDriverOptions {
|
|
3499
|
-
client:
|
|
3501
|
+
client: WeftHttpClient;
|
|
3500
3502
|
sessionId: string;
|
|
3501
3503
|
/** LLM model override sent to Flitro */
|
|
3502
3504
|
model?: string;
|
|
@@ -3537,7 +3539,7 @@ interface FlitroCapabilityProbeResult {
|
|
|
3537
3539
|
* process (the Go agentd binary) that the TypeScript provider communicates
|
|
3538
3540
|
* with over HTTP.
|
|
3539
3541
|
*/
|
|
3540
|
-
declare function probeFlitroCapabilities(client:
|
|
3542
|
+
declare function probeFlitroCapabilities(client: WeftHttpClient): Promise<FlitroCapabilityProbeResult>;
|
|
3541
3543
|
|
|
3542
3544
|
/**
|
|
3543
3545
|
* @weft/provider-flitro
|
|
@@ -3570,7 +3572,7 @@ interface CreateFlitroRuntimeCapabilityReportOptions {
|
|
|
3570
3572
|
declare function createFlitroRuntimeCapabilityReport(options: CreateFlitroRuntimeCapabilityReportOptions): RuntimeCapabilityReport;
|
|
3571
3573
|
interface CreateFlitroProviderRuntimeOptions extends CreateFlitroRuntimeCapabilityReportOptions {
|
|
3572
3574
|
/** Flitro server connection options */
|
|
3573
|
-
server:
|
|
3575
|
+
server: WeftHttpClientOptions;
|
|
3574
3576
|
/** Session ID — if omitted a new session is created on first sendMessage */
|
|
3575
3577
|
sessionId?: string;
|
|
3576
3578
|
/** Epoch string for the timeline (default: derived from sessionId) */
|
|
@@ -3630,7 +3632,7 @@ interface CreateFlitroEmbedRuntimeOptions {
|
|
|
3630
3632
|
declare function createFlitroEmbedRuntime(options: CreateFlitroEmbedRuntimeOptions): AgentRuntime;
|
|
3631
3633
|
interface CreateFlitroRuntimeOptions {
|
|
3632
3634
|
/** Flitro server connection options */
|
|
3633
|
-
server:
|
|
3635
|
+
server: WeftHttpClientOptions;
|
|
3634
3636
|
sessionId?: string;
|
|
3635
3637
|
epoch?: string;
|
|
3636
3638
|
now?: () => number;
|