@percena/weft 0.4.0-next.4 → 0.4.0-next.6
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 +7 -883
- package/dist/chat.d.cts +13 -13
- package/dist/chat.d.ts +13 -13
- package/dist/chat.js +7 -883
- package/dist/index.cjs +96 -103
- package/dist/index.js +96 -103
- package/dist/providers-flitro.cjs +2 -276
- package/dist/providers-flitro.d.cts +2 -1
- package/dist/providers-flitro.d.ts +2 -1
- package/dist/providers-flitro.js +1 -260
- package/dist/styles/fonts/KaTeX_AMS-Regular.ttf +0 -0
- package/dist/styles/fonts/KaTeX_AMS-Regular.woff +0 -0
- package/dist/styles/fonts/KaTeX_AMS-Regular.woff2 +0 -0
- package/dist/styles/fonts/KaTeX_Caligraphic-Bold.ttf +0 -0
- package/dist/styles/fonts/KaTeX_Caligraphic-Bold.woff +0 -0
- package/dist/styles/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
- package/dist/styles/fonts/KaTeX_Caligraphic-Regular.ttf +0 -0
- package/dist/styles/fonts/KaTeX_Caligraphic-Regular.woff +0 -0
- package/dist/styles/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
- package/dist/styles/fonts/KaTeX_Fraktur-Bold.ttf +0 -0
- package/dist/styles/fonts/KaTeX_Fraktur-Bold.woff +0 -0
- package/dist/styles/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
- package/dist/styles/fonts/KaTeX_Fraktur-Regular.ttf +0 -0
- package/dist/styles/fonts/KaTeX_Fraktur-Regular.woff +0 -0
- package/dist/styles/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
- package/dist/styles/fonts/KaTeX_Main-Bold.ttf +0 -0
- package/dist/styles/fonts/KaTeX_Main-Bold.woff +0 -0
- package/dist/styles/fonts/KaTeX_Main-Bold.woff2 +0 -0
- package/dist/styles/fonts/KaTeX_Main-BoldItalic.ttf +0 -0
- package/dist/styles/fonts/KaTeX_Main-BoldItalic.woff +0 -0
- package/dist/styles/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
- package/dist/styles/fonts/KaTeX_Main-Italic.ttf +0 -0
- package/dist/styles/fonts/KaTeX_Main-Italic.woff +0 -0
- package/dist/styles/fonts/KaTeX_Main-Italic.woff2 +0 -0
- package/dist/styles/fonts/KaTeX_Main-Regular.ttf +0 -0
- package/dist/styles/fonts/KaTeX_Main-Regular.woff +0 -0
- package/dist/styles/fonts/KaTeX_Main-Regular.woff2 +0 -0
- package/dist/styles/fonts/KaTeX_Math-BoldItalic.ttf +0 -0
- package/dist/styles/fonts/KaTeX_Math-BoldItalic.woff +0 -0
- package/dist/styles/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
- package/dist/styles/fonts/KaTeX_Math-Italic.ttf +0 -0
- package/dist/styles/fonts/KaTeX_Math-Italic.woff +0 -0
- package/dist/styles/fonts/KaTeX_Math-Italic.woff2 +0 -0
- package/dist/styles/fonts/KaTeX_SansSerif-Bold.ttf +0 -0
- package/dist/styles/fonts/KaTeX_SansSerif-Bold.woff +0 -0
- package/dist/styles/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
- package/dist/styles/fonts/KaTeX_SansSerif-Italic.ttf +0 -0
- package/dist/styles/fonts/KaTeX_SansSerif-Italic.woff +0 -0
- package/dist/styles/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
- package/dist/styles/fonts/KaTeX_SansSerif-Regular.ttf +0 -0
- package/dist/styles/fonts/KaTeX_SansSerif-Regular.woff +0 -0
- package/dist/styles/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
- package/dist/styles/fonts/KaTeX_Script-Regular.ttf +0 -0
- package/dist/styles/fonts/KaTeX_Script-Regular.woff +0 -0
- package/dist/styles/fonts/KaTeX_Script-Regular.woff2 +0 -0
- package/dist/styles/fonts/KaTeX_Size1-Regular.ttf +0 -0
- package/dist/styles/fonts/KaTeX_Size1-Regular.woff +0 -0
- package/dist/styles/fonts/KaTeX_Size1-Regular.woff2 +0 -0
- package/dist/styles/fonts/KaTeX_Size2-Regular.ttf +0 -0
- package/dist/styles/fonts/KaTeX_Size2-Regular.woff +0 -0
- package/dist/styles/fonts/KaTeX_Size2-Regular.woff2 +0 -0
- package/dist/styles/fonts/KaTeX_Size3-Regular.ttf +0 -0
- package/dist/styles/fonts/KaTeX_Size3-Regular.woff +0 -0
- package/dist/styles/fonts/KaTeX_Size3-Regular.woff2 +0 -0
- package/dist/styles/fonts/KaTeX_Size4-Regular.ttf +0 -0
- package/dist/styles/fonts/KaTeX_Size4-Regular.woff +0 -0
- package/dist/styles/fonts/KaTeX_Size4-Regular.woff2 +0 -0
- package/dist/styles/fonts/KaTeX_Typewriter-Regular.ttf +0 -0
- package/dist/styles/fonts/KaTeX_Typewriter-Regular.woff +0 -0
- package/dist/styles/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
- package/package.json +1 -1
|
@@ -23,9 +23,7 @@ __export(providers_flitro_exports, {
|
|
|
23
23
|
FlitroFetchSseTimelineStream: () => FlitroFetchSseTimelineStream,
|
|
24
24
|
FlitroHttpClient: () => FlitroHttpClient,
|
|
25
25
|
FlitroSseTimelineStream: () => FlitroSseTimelineStream,
|
|
26
|
-
RUNTIME_KINDS: () => RUNTIME_KINDS,
|
|
27
26
|
WeftClient: () => WeftClient,
|
|
28
|
-
appendTimelineItem: () => appendTimelineItem,
|
|
29
27
|
createFlitroDriver: () => createFlitroDriver,
|
|
30
28
|
createFlitroEmbedRuntime: () => createFlitroEmbedRuntime,
|
|
31
29
|
createFlitroProviderRuntime: () => createFlitroProviderRuntime,
|
|
@@ -33,41 +31,12 @@ __export(providers_flitro_exports, {
|
|
|
33
31
|
createFlitroRuntimeCandidates: () => createFlitroRuntimeCandidates,
|
|
34
32
|
createFlitroRuntimeCapabilityReport: () => createFlitroRuntimeCapabilityReport,
|
|
35
33
|
createFlitroTimelineStream: () => createFlitroTimelineStream,
|
|
36
|
-
|
|
37
|
-
createRuntimeExtensionContext: () => createRuntimeExtensionContext,
|
|
38
|
-
createTimelineCursor: () => createTimelineCursor,
|
|
39
|
-
createTimelineSequencer: () => createTimelineSequencer,
|
|
40
|
-
fetchTimeline: () => fetchTimeline,
|
|
41
|
-
initialRuntimeState: () => initialRuntimeState,
|
|
42
|
-
invokeSessionTool: () => invokeSessionTool,
|
|
43
|
-
mapCodexSandboxModeToSandboxPolicy: () => mapCodexSandboxModeToSandboxPolicy,
|
|
44
|
-
mapPermissionModeToCodexParams: () => mapPermissionModeToCodexParams,
|
|
45
|
-
mergeTimeline: () => mergeTimeline,
|
|
46
|
-
probeFlitroCapabilities: () => probeFlitroCapabilities,
|
|
47
|
-
reduceRuntimeState: () => reduceRuntimeState,
|
|
48
|
-
sanitizeProviderSourceTools: () => sanitizeProviderSourceTools,
|
|
49
|
-
selectRuntimeCandidate: () => selectRuntimeCandidate
|
|
34
|
+
probeFlitroCapabilities: () => probeFlitroCapabilities
|
|
50
35
|
});
|
|
51
36
|
module.exports = __toCommonJS(providers_flitro_exports);
|
|
52
37
|
|
|
53
38
|
// ../packages/runtime-core/dist/index.js
|
|
54
39
|
var RUNTIME_KINDS = ["native-sdk", "app-server", "compatible-sdk", "cli-fallback"];
|
|
55
|
-
function mapPermissionModeToCodexParams(mode) {
|
|
56
|
-
switch (mode) {
|
|
57
|
-
case "safe":
|
|
58
|
-
return { approvalPolicy: "untrusted", approvalsReviewer: "user", sandbox: "read-only" };
|
|
59
|
-
case "allow-all":
|
|
60
|
-
return { approvalPolicy: "never", approvalsReviewer: "user", sandbox: "danger-full-access" };
|
|
61
|
-
case "ask":
|
|
62
|
-
default:
|
|
63
|
-
return { approvalPolicy: "on-request", approvalsReviewer: "user", sandbox: "workspace-write" };
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
function mapCodexSandboxModeToSandboxPolicy(sandbox) {
|
|
67
|
-
if (sandbox === "read-only") return { type: "readOnly" };
|
|
68
|
-
if (sandbox === "danger-full-access") return { type: "dangerFullAccess" };
|
|
69
|
-
return { type: "workspaceWrite" };
|
|
70
|
-
}
|
|
71
40
|
var initialRuntimeState = {
|
|
72
41
|
status: "idle",
|
|
73
42
|
acceptedMessages: [],
|
|
@@ -167,203 +136,9 @@ function createRuntimeExtensionContext(context = {}) {
|
|
|
167
136
|
hostServices: context.hostServices
|
|
168
137
|
};
|
|
169
138
|
}
|
|
170
|
-
function sanitizeProviderSourceTools(sourceTools) {
|
|
171
|
-
if (!sourceTools || sourceTools.length === 0) return [];
|
|
172
|
-
const sanitized = [];
|
|
173
|
-
for (const sourceTool of sourceTools) {
|
|
174
|
-
if (sourceTool.kind === "api-source") {
|
|
175
|
-
const defaultHeaders = sourceTool.defaultHeaders ? copyNonCredentialStringRecord(sourceTool.defaultHeaders) : void 0;
|
|
176
|
-
sanitized.push({
|
|
177
|
-
kind: "api-source",
|
|
178
|
-
sourceSlug: sourceTool.sourceSlug,
|
|
179
|
-
baseUrl: sourceTool.baseUrl,
|
|
180
|
-
authType: sourceTool.authType,
|
|
181
|
-
...defaultHeaders && Object.keys(defaultHeaders).length > 0 ? { defaultHeaders } : {},
|
|
182
|
-
...sourceTool.credentialRef ? { credentialRef: sanitizeSourceCredentialRef(sourceTool.credentialRef) } : {}
|
|
183
|
-
});
|
|
184
|
-
continue;
|
|
185
|
-
}
|
|
186
|
-
if (sourceTool.kind === "local-source") {
|
|
187
|
-
sanitized.push({
|
|
188
|
-
kind: "local-source",
|
|
189
|
-
sourceSlug: sourceTool.sourceSlug,
|
|
190
|
-
path: sourceTool.path,
|
|
191
|
-
...sourceTool.format ? { format: sourceTool.format } : {}
|
|
192
|
-
});
|
|
193
|
-
continue;
|
|
194
|
-
}
|
|
195
|
-
if (sourceTool.kind === "mcp-server") {
|
|
196
|
-
const env = sourceTool.env ? copyNonCredentialStringRecord(sourceTool.env) : void 0;
|
|
197
|
-
const headers = sourceTool.headers ? copyNonCredentialStringRecord(sourceTool.headers) : void 0;
|
|
198
|
-
sanitized.push({
|
|
199
|
-
kind: "mcp-server",
|
|
200
|
-
sourceSlug: sourceTool.sourceSlug,
|
|
201
|
-
transport: sourceTool.transport,
|
|
202
|
-
...sourceTool.url ? { url: sourceTool.url } : {},
|
|
203
|
-
...sourceTool.command ? { command: sourceTool.command } : {},
|
|
204
|
-
...sourceTool.args ? { args: sourceTool.args.filter((value) => typeof value === "string") } : {},
|
|
205
|
-
...env && Object.keys(env).length > 0 ? { env } : {},
|
|
206
|
-
...headers && Object.keys(headers).length > 0 ? { headers } : {},
|
|
207
|
-
...sourceTool.credentialRef ? { credentialRef: sanitizeSourceCredentialRef(sourceTool.credentialRef) } : {}
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
return sanitized;
|
|
212
|
-
}
|
|
213
|
-
var sessionToolRequestCounter = 0;
|
|
214
|
-
async function invokeSessionTool(options) {
|
|
215
|
-
const requestId = `session-tool-${++sessionToolRequestCounter}`;
|
|
216
|
-
const origin = originFromSessionToolRequest(options.request) ?? options.commandOrigin;
|
|
217
|
-
const policyDecision = await evaluateSessionToolPolicy(options, requestId);
|
|
218
|
-
const timelineRefs = [];
|
|
219
|
-
const append = (item) => {
|
|
220
|
-
const envelope = options.appendTimeline?.(item);
|
|
221
|
-
if (envelope) {
|
|
222
|
-
timelineRefs.push({ epoch: envelope.epoch, seq: envelope.seq });
|
|
223
|
-
}
|
|
224
|
-
};
|
|
225
|
-
if (policyDecision.decision !== "allow") {
|
|
226
|
-
const reason = policyDecision.decision === "deny" ? policyDecision.reason : policyDecision.reason;
|
|
227
|
-
append({
|
|
228
|
-
type: "host_state_changed",
|
|
229
|
-
state: {
|
|
230
|
-
kind: "host_tool_denied",
|
|
231
|
-
requestId,
|
|
232
|
-
toolName: options.toolName,
|
|
233
|
-
reason
|
|
234
|
-
}
|
|
235
|
-
});
|
|
236
|
-
return {
|
|
237
|
-
ok: false,
|
|
238
|
-
requestId,
|
|
239
|
-
toolName: options.toolName,
|
|
240
|
-
origin,
|
|
241
|
-
policyDecision,
|
|
242
|
-
reason,
|
|
243
|
-
timelineRefs
|
|
244
|
-
};
|
|
245
|
-
}
|
|
246
|
-
append({
|
|
247
|
-
type: "host_state_changed",
|
|
248
|
-
state: {
|
|
249
|
-
kind: "host_tool_invoked",
|
|
250
|
-
requestId,
|
|
251
|
-
toolName: options.toolName,
|
|
252
|
-
...origin ? { origin } : {}
|
|
253
|
-
}
|
|
254
|
-
});
|
|
255
|
-
const callback = options.bridge[options.toolName];
|
|
256
|
-
if (!callback) {
|
|
257
|
-
const reason = `Session tool bridge callback is not registered: ${String(options.toolName)}`;
|
|
258
|
-
append({
|
|
259
|
-
type: "host_state_changed",
|
|
260
|
-
state: {
|
|
261
|
-
kind: "host_tool_result",
|
|
262
|
-
requestId,
|
|
263
|
-
toolName: options.toolName,
|
|
264
|
-
ok: false,
|
|
265
|
-
reason
|
|
266
|
-
}
|
|
267
|
-
});
|
|
268
|
-
return {
|
|
269
|
-
ok: false,
|
|
270
|
-
requestId,
|
|
271
|
-
toolName: options.toolName,
|
|
272
|
-
origin,
|
|
273
|
-
policyDecision,
|
|
274
|
-
reason,
|
|
275
|
-
timelineRefs
|
|
276
|
-
};
|
|
277
|
-
}
|
|
278
|
-
try {
|
|
279
|
-
const result = await callback(options.request);
|
|
280
|
-
append({
|
|
281
|
-
type: "host_state_changed",
|
|
282
|
-
state: {
|
|
283
|
-
kind: "host_tool_result",
|
|
284
|
-
requestId,
|
|
285
|
-
toolName: options.toolName,
|
|
286
|
-
ok: true
|
|
287
|
-
}
|
|
288
|
-
});
|
|
289
|
-
return {
|
|
290
|
-
ok: true,
|
|
291
|
-
requestId,
|
|
292
|
-
toolName: options.toolName,
|
|
293
|
-
origin,
|
|
294
|
-
policyDecision,
|
|
295
|
-
result,
|
|
296
|
-
timelineRefs
|
|
297
|
-
};
|
|
298
|
-
} catch (error) {
|
|
299
|
-
const reason = error instanceof Error ? error.message : String(error);
|
|
300
|
-
append({
|
|
301
|
-
type: "host_state_changed",
|
|
302
|
-
state: {
|
|
303
|
-
kind: "host_tool_result",
|
|
304
|
-
requestId,
|
|
305
|
-
toolName: options.toolName,
|
|
306
|
-
ok: false,
|
|
307
|
-
reason
|
|
308
|
-
}
|
|
309
|
-
});
|
|
310
|
-
return {
|
|
311
|
-
ok: false,
|
|
312
|
-
requestId,
|
|
313
|
-
toolName: options.toolName,
|
|
314
|
-
origin,
|
|
315
|
-
policyDecision,
|
|
316
|
-
reason,
|
|
317
|
-
timelineRefs
|
|
318
|
-
};
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
async function evaluateSessionToolPolicy(options, requestId) {
|
|
322
|
-
if (!options.policy) return { decision: "allow" };
|
|
323
|
-
return options.policy({
|
|
324
|
-
toolName: `host.${String(options.toolName)}`,
|
|
325
|
-
input: recordFromSessionToolRequest(options.request),
|
|
326
|
-
toolIntent: { kind: "unknown", toolName: `host.${String(options.toolName)}` },
|
|
327
|
-
scope: { type: "session", sessionId: options.sessionId }
|
|
328
|
-
});
|
|
329
|
-
}
|
|
330
|
-
function originFromSessionToolRequest(request) {
|
|
331
|
-
const record = recordFromSessionToolRequest(request);
|
|
332
|
-
const origin = record.origin ?? record.commandOrigin;
|
|
333
|
-
return isCommandOrigin(origin) ? origin : void 0;
|
|
334
|
-
}
|
|
335
|
-
function recordFromSessionToolRequest(request) {
|
|
336
|
-
return request && typeof request === "object" ? { ...request } : {};
|
|
337
|
-
}
|
|
338
|
-
function isCommandOrigin(value) {
|
|
339
|
-
if (!value || typeof value !== "object") return false;
|
|
340
|
-
const type = value.type;
|
|
341
|
-
return type === "user" || type === "automation" || type === "scheduler" || type === "host" || type === "replay" || type === "system";
|
|
342
|
-
}
|
|
343
139
|
function unique(values) {
|
|
344
140
|
return [...new Set(values)];
|
|
345
141
|
}
|
|
346
|
-
function sanitizeSourceCredentialRef(credentialRef) {
|
|
347
|
-
return {
|
|
348
|
-
type: credentialRef.type,
|
|
349
|
-
sourceSlug: credentialRef.sourceSlug,
|
|
350
|
-
...credentialRef.workspaceId ? { workspaceId: credentialRef.workspaceId } : {}
|
|
351
|
-
};
|
|
352
|
-
}
|
|
353
|
-
function copyStringRecord(record) {
|
|
354
|
-
return Object.fromEntries(
|
|
355
|
-
Object.entries(record).filter((entry) => typeof entry[0] === "string" && typeof entry[1] === "string")
|
|
356
|
-
);
|
|
357
|
-
}
|
|
358
|
-
function copyNonCredentialStringRecord(record) {
|
|
359
|
-
return Object.fromEntries(
|
|
360
|
-
Object.entries(copyStringRecord(record)).filter(([key]) => !isCredentialKey(key))
|
|
361
|
-
);
|
|
362
|
-
}
|
|
363
|
-
function isCredentialKey(key) {
|
|
364
|
-
const normalized = key.toLowerCase();
|
|
365
|
-
return normalized === "authorization" || normalized === "proxy-authorization" || normalized === "cookie" || normalized === "set-cookie" || normalized.includes("api-key") || normalized.includes("apikey") || normalized.includes("token") || normalized.includes("secret") || normalized.includes("password");
|
|
366
|
-
}
|
|
367
142
|
function findCandidate(candidates, kind) {
|
|
368
143
|
return candidates.find((candidate) => candidate.kind === kind);
|
|
369
144
|
}
|
|
@@ -450,30 +225,6 @@ function normalizeExtensionCapabilities(capabilities = {}) {
|
|
|
450
225
|
}
|
|
451
226
|
|
|
452
227
|
// ../packages/timeline/dist/index.js
|
|
453
|
-
function createTimelineSequencer(options) {
|
|
454
|
-
let seq = options.startSeq ?? 0;
|
|
455
|
-
const now = options.now ?? Date.now;
|
|
456
|
-
return {
|
|
457
|
-
append(item, rawRef) {
|
|
458
|
-
seq += 1;
|
|
459
|
-
return appendTimelineItem({
|
|
460
|
-
sessionId: options.sessionId,
|
|
461
|
-
provider: options.provider,
|
|
462
|
-
epoch: options.epoch,
|
|
463
|
-
seq,
|
|
464
|
-
timestamp: now(),
|
|
465
|
-
item,
|
|
466
|
-
rawRef
|
|
467
|
-
});
|
|
468
|
-
}
|
|
469
|
-
};
|
|
470
|
-
}
|
|
471
|
-
function appendTimelineItem(envelope) {
|
|
472
|
-
return {
|
|
473
|
-
...envelope,
|
|
474
|
-
rawRef: envelope.rawRef ? { ...envelope.rawRef } : void 0
|
|
475
|
-
};
|
|
476
|
-
}
|
|
477
228
|
function createTimelineCursor(cursor) {
|
|
478
229
|
return {
|
|
479
230
|
epoch: cursor.epoch,
|
|
@@ -495,13 +246,6 @@ function fetchTimeline(timeline, request = {}) {
|
|
|
495
246
|
hasGap: firstSeq !== void 0 && firstSeq > cursor.afterSeq + 1
|
|
496
247
|
};
|
|
497
248
|
}
|
|
498
|
-
function mergeTimeline(existing, incoming) {
|
|
499
|
-
const byKey = /* @__PURE__ */ new Map();
|
|
500
|
-
for (const item of [...existing, ...incoming]) {
|
|
501
|
-
byKey.set(timelineKey(item), item);
|
|
502
|
-
}
|
|
503
|
-
return sortTimeline([...byKey.values()]);
|
|
504
|
-
}
|
|
505
249
|
function cursorFromTimelineStart(timeline) {
|
|
506
250
|
return {
|
|
507
251
|
epoch: timeline[0]?.epoch ?? "default",
|
|
@@ -514,9 +258,6 @@ function sortTimeline(timeline) {
|
|
|
514
258
|
return left.seq - right.seq;
|
|
515
259
|
});
|
|
516
260
|
}
|
|
517
|
-
function timelineKey(item) {
|
|
518
|
-
return `${item.epoch}:${item.seq}`;
|
|
519
|
-
}
|
|
520
261
|
|
|
521
262
|
// ../packages/client/dist/index.js
|
|
522
263
|
var FlitroHttpClient = class {
|
|
@@ -1491,9 +1232,7 @@ async function createFlitroRuntime(options) {
|
|
|
1491
1232
|
FlitroFetchSseTimelineStream,
|
|
1492
1233
|
FlitroHttpClient,
|
|
1493
1234
|
FlitroSseTimelineStream,
|
|
1494
|
-
RUNTIME_KINDS,
|
|
1495
1235
|
WeftClient,
|
|
1496
|
-
appendTimelineItem,
|
|
1497
1236
|
createFlitroDriver,
|
|
1498
1237
|
createFlitroEmbedRuntime,
|
|
1499
1238
|
createFlitroProviderRuntime,
|
|
@@ -1501,18 +1240,5 @@ async function createFlitroRuntime(options) {
|
|
|
1501
1240
|
createFlitroRuntimeCandidates,
|
|
1502
1241
|
createFlitroRuntimeCapabilityReport,
|
|
1503
1242
|
createFlitroTimelineStream,
|
|
1504
|
-
|
|
1505
|
-
createRuntimeExtensionContext,
|
|
1506
|
-
createTimelineCursor,
|
|
1507
|
-
createTimelineSequencer,
|
|
1508
|
-
fetchTimeline,
|
|
1509
|
-
initialRuntimeState,
|
|
1510
|
-
invokeSessionTool,
|
|
1511
|
-
mapCodexSandboxModeToSandboxPolicy,
|
|
1512
|
-
mapPermissionModeToCodexParams,
|
|
1513
|
-
mergeTimeline,
|
|
1514
|
-
probeFlitroCapabilities,
|
|
1515
|
-
reduceRuntimeState,
|
|
1516
|
-
sanitizeProviderSourceTools,
|
|
1517
|
-
selectRuntimeCandidate
|
|
1243
|
+
probeFlitroCapabilities
|
|
1518
1244
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
export { AgentCommandSink, AgentEventStream, AgentRuntime, AgentRuntimeKind, AgentRuntimeState, AgentRuntimeStatus, AgentTimelineStream, SendMessageOptions };
|
|
2
|
+
export { TimelineCursor, TimelineEnvelope, TimelineFetchRequest, TimelineFetchResult, TimelineItem, TimelinePermissionRequest, TimelinePermissionResolution };
|
|
2
3
|
|
|
3
4
|
// ── inlined from @weft/core ──
|
|
4
5
|
// -- @weft/core/index.d.ts --
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
export { AgentCommandSink, AgentEventStream, AgentRuntime, AgentRuntimeKind, AgentRuntimeState, AgentRuntimeStatus, AgentTimelineStream, SendMessageOptions };
|
|
2
|
+
export { TimelineCursor, TimelineEnvelope, TimelineFetchRequest, TimelineFetchResult, TimelineItem, TimelinePermissionRequest, TimelinePermissionResolution };
|
|
2
3
|
|
|
3
4
|
// ── inlined from @weft/core ──
|
|
4
5
|
// -- @weft/core/index.d.ts --
|
package/dist/providers-flitro.js
CHANGED
|
@@ -1,21 +1,5 @@
|
|
|
1
1
|
// ../packages/runtime-core/dist/index.js
|
|
2
2
|
var RUNTIME_KINDS = ["native-sdk", "app-server", "compatible-sdk", "cli-fallback"];
|
|
3
|
-
function mapPermissionModeToCodexParams(mode) {
|
|
4
|
-
switch (mode) {
|
|
5
|
-
case "safe":
|
|
6
|
-
return { approvalPolicy: "untrusted", approvalsReviewer: "user", sandbox: "read-only" };
|
|
7
|
-
case "allow-all":
|
|
8
|
-
return { approvalPolicy: "never", approvalsReviewer: "user", sandbox: "danger-full-access" };
|
|
9
|
-
case "ask":
|
|
10
|
-
default:
|
|
11
|
-
return { approvalPolicy: "on-request", approvalsReviewer: "user", sandbox: "workspace-write" };
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
function mapCodexSandboxModeToSandboxPolicy(sandbox) {
|
|
15
|
-
if (sandbox === "read-only") return { type: "readOnly" };
|
|
16
|
-
if (sandbox === "danger-full-access") return { type: "dangerFullAccess" };
|
|
17
|
-
return { type: "workspaceWrite" };
|
|
18
|
-
}
|
|
19
3
|
var initialRuntimeState = {
|
|
20
4
|
status: "idle",
|
|
21
5
|
acceptedMessages: [],
|
|
@@ -115,203 +99,9 @@ function createRuntimeExtensionContext(context = {}) {
|
|
|
115
99
|
hostServices: context.hostServices
|
|
116
100
|
};
|
|
117
101
|
}
|
|
118
|
-
function sanitizeProviderSourceTools(sourceTools) {
|
|
119
|
-
if (!sourceTools || sourceTools.length === 0) return [];
|
|
120
|
-
const sanitized = [];
|
|
121
|
-
for (const sourceTool of sourceTools) {
|
|
122
|
-
if (sourceTool.kind === "api-source") {
|
|
123
|
-
const defaultHeaders = sourceTool.defaultHeaders ? copyNonCredentialStringRecord(sourceTool.defaultHeaders) : void 0;
|
|
124
|
-
sanitized.push({
|
|
125
|
-
kind: "api-source",
|
|
126
|
-
sourceSlug: sourceTool.sourceSlug,
|
|
127
|
-
baseUrl: sourceTool.baseUrl,
|
|
128
|
-
authType: sourceTool.authType,
|
|
129
|
-
...defaultHeaders && Object.keys(defaultHeaders).length > 0 ? { defaultHeaders } : {},
|
|
130
|
-
...sourceTool.credentialRef ? { credentialRef: sanitizeSourceCredentialRef(sourceTool.credentialRef) } : {}
|
|
131
|
-
});
|
|
132
|
-
continue;
|
|
133
|
-
}
|
|
134
|
-
if (sourceTool.kind === "local-source") {
|
|
135
|
-
sanitized.push({
|
|
136
|
-
kind: "local-source",
|
|
137
|
-
sourceSlug: sourceTool.sourceSlug,
|
|
138
|
-
path: sourceTool.path,
|
|
139
|
-
...sourceTool.format ? { format: sourceTool.format } : {}
|
|
140
|
-
});
|
|
141
|
-
continue;
|
|
142
|
-
}
|
|
143
|
-
if (sourceTool.kind === "mcp-server") {
|
|
144
|
-
const env = sourceTool.env ? copyNonCredentialStringRecord(sourceTool.env) : void 0;
|
|
145
|
-
const headers = sourceTool.headers ? copyNonCredentialStringRecord(sourceTool.headers) : void 0;
|
|
146
|
-
sanitized.push({
|
|
147
|
-
kind: "mcp-server",
|
|
148
|
-
sourceSlug: sourceTool.sourceSlug,
|
|
149
|
-
transport: sourceTool.transport,
|
|
150
|
-
...sourceTool.url ? { url: sourceTool.url } : {},
|
|
151
|
-
...sourceTool.command ? { command: sourceTool.command } : {},
|
|
152
|
-
...sourceTool.args ? { args: sourceTool.args.filter((value) => typeof value === "string") } : {},
|
|
153
|
-
...env && Object.keys(env).length > 0 ? { env } : {},
|
|
154
|
-
...headers && Object.keys(headers).length > 0 ? { headers } : {},
|
|
155
|
-
...sourceTool.credentialRef ? { credentialRef: sanitizeSourceCredentialRef(sourceTool.credentialRef) } : {}
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
return sanitized;
|
|
160
|
-
}
|
|
161
|
-
var sessionToolRequestCounter = 0;
|
|
162
|
-
async function invokeSessionTool(options) {
|
|
163
|
-
const requestId = `session-tool-${++sessionToolRequestCounter}`;
|
|
164
|
-
const origin = originFromSessionToolRequest(options.request) ?? options.commandOrigin;
|
|
165
|
-
const policyDecision = await evaluateSessionToolPolicy(options, requestId);
|
|
166
|
-
const timelineRefs = [];
|
|
167
|
-
const append = (item) => {
|
|
168
|
-
const envelope = options.appendTimeline?.(item);
|
|
169
|
-
if (envelope) {
|
|
170
|
-
timelineRefs.push({ epoch: envelope.epoch, seq: envelope.seq });
|
|
171
|
-
}
|
|
172
|
-
};
|
|
173
|
-
if (policyDecision.decision !== "allow") {
|
|
174
|
-
const reason = policyDecision.decision === "deny" ? policyDecision.reason : policyDecision.reason;
|
|
175
|
-
append({
|
|
176
|
-
type: "host_state_changed",
|
|
177
|
-
state: {
|
|
178
|
-
kind: "host_tool_denied",
|
|
179
|
-
requestId,
|
|
180
|
-
toolName: options.toolName,
|
|
181
|
-
reason
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
return {
|
|
185
|
-
ok: false,
|
|
186
|
-
requestId,
|
|
187
|
-
toolName: options.toolName,
|
|
188
|
-
origin,
|
|
189
|
-
policyDecision,
|
|
190
|
-
reason,
|
|
191
|
-
timelineRefs
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
append({
|
|
195
|
-
type: "host_state_changed",
|
|
196
|
-
state: {
|
|
197
|
-
kind: "host_tool_invoked",
|
|
198
|
-
requestId,
|
|
199
|
-
toolName: options.toolName,
|
|
200
|
-
...origin ? { origin } : {}
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
const callback = options.bridge[options.toolName];
|
|
204
|
-
if (!callback) {
|
|
205
|
-
const reason = `Session tool bridge callback is not registered: ${String(options.toolName)}`;
|
|
206
|
-
append({
|
|
207
|
-
type: "host_state_changed",
|
|
208
|
-
state: {
|
|
209
|
-
kind: "host_tool_result",
|
|
210
|
-
requestId,
|
|
211
|
-
toolName: options.toolName,
|
|
212
|
-
ok: false,
|
|
213
|
-
reason
|
|
214
|
-
}
|
|
215
|
-
});
|
|
216
|
-
return {
|
|
217
|
-
ok: false,
|
|
218
|
-
requestId,
|
|
219
|
-
toolName: options.toolName,
|
|
220
|
-
origin,
|
|
221
|
-
policyDecision,
|
|
222
|
-
reason,
|
|
223
|
-
timelineRefs
|
|
224
|
-
};
|
|
225
|
-
}
|
|
226
|
-
try {
|
|
227
|
-
const result = await callback(options.request);
|
|
228
|
-
append({
|
|
229
|
-
type: "host_state_changed",
|
|
230
|
-
state: {
|
|
231
|
-
kind: "host_tool_result",
|
|
232
|
-
requestId,
|
|
233
|
-
toolName: options.toolName,
|
|
234
|
-
ok: true
|
|
235
|
-
}
|
|
236
|
-
});
|
|
237
|
-
return {
|
|
238
|
-
ok: true,
|
|
239
|
-
requestId,
|
|
240
|
-
toolName: options.toolName,
|
|
241
|
-
origin,
|
|
242
|
-
policyDecision,
|
|
243
|
-
result,
|
|
244
|
-
timelineRefs
|
|
245
|
-
};
|
|
246
|
-
} catch (error) {
|
|
247
|
-
const reason = error instanceof Error ? error.message : String(error);
|
|
248
|
-
append({
|
|
249
|
-
type: "host_state_changed",
|
|
250
|
-
state: {
|
|
251
|
-
kind: "host_tool_result",
|
|
252
|
-
requestId,
|
|
253
|
-
toolName: options.toolName,
|
|
254
|
-
ok: false,
|
|
255
|
-
reason
|
|
256
|
-
}
|
|
257
|
-
});
|
|
258
|
-
return {
|
|
259
|
-
ok: false,
|
|
260
|
-
requestId,
|
|
261
|
-
toolName: options.toolName,
|
|
262
|
-
origin,
|
|
263
|
-
policyDecision,
|
|
264
|
-
reason,
|
|
265
|
-
timelineRefs
|
|
266
|
-
};
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
async function evaluateSessionToolPolicy(options, requestId) {
|
|
270
|
-
if (!options.policy) return { decision: "allow" };
|
|
271
|
-
return options.policy({
|
|
272
|
-
toolName: `host.${String(options.toolName)}`,
|
|
273
|
-
input: recordFromSessionToolRequest(options.request),
|
|
274
|
-
toolIntent: { kind: "unknown", toolName: `host.${String(options.toolName)}` },
|
|
275
|
-
scope: { type: "session", sessionId: options.sessionId }
|
|
276
|
-
});
|
|
277
|
-
}
|
|
278
|
-
function originFromSessionToolRequest(request) {
|
|
279
|
-
const record = recordFromSessionToolRequest(request);
|
|
280
|
-
const origin = record.origin ?? record.commandOrigin;
|
|
281
|
-
return isCommandOrigin(origin) ? origin : void 0;
|
|
282
|
-
}
|
|
283
|
-
function recordFromSessionToolRequest(request) {
|
|
284
|
-
return request && typeof request === "object" ? { ...request } : {};
|
|
285
|
-
}
|
|
286
|
-
function isCommandOrigin(value) {
|
|
287
|
-
if (!value || typeof value !== "object") return false;
|
|
288
|
-
const type = value.type;
|
|
289
|
-
return type === "user" || type === "automation" || type === "scheduler" || type === "host" || type === "replay" || type === "system";
|
|
290
|
-
}
|
|
291
102
|
function unique(values) {
|
|
292
103
|
return [...new Set(values)];
|
|
293
104
|
}
|
|
294
|
-
function sanitizeSourceCredentialRef(credentialRef) {
|
|
295
|
-
return {
|
|
296
|
-
type: credentialRef.type,
|
|
297
|
-
sourceSlug: credentialRef.sourceSlug,
|
|
298
|
-
...credentialRef.workspaceId ? { workspaceId: credentialRef.workspaceId } : {}
|
|
299
|
-
};
|
|
300
|
-
}
|
|
301
|
-
function copyStringRecord(record) {
|
|
302
|
-
return Object.fromEntries(
|
|
303
|
-
Object.entries(record).filter((entry) => typeof entry[0] === "string" && typeof entry[1] === "string")
|
|
304
|
-
);
|
|
305
|
-
}
|
|
306
|
-
function copyNonCredentialStringRecord(record) {
|
|
307
|
-
return Object.fromEntries(
|
|
308
|
-
Object.entries(copyStringRecord(record)).filter(([key]) => !isCredentialKey(key))
|
|
309
|
-
);
|
|
310
|
-
}
|
|
311
|
-
function isCredentialKey(key) {
|
|
312
|
-
const normalized = key.toLowerCase();
|
|
313
|
-
return normalized === "authorization" || normalized === "proxy-authorization" || normalized === "cookie" || normalized === "set-cookie" || normalized.includes("api-key") || normalized.includes("apikey") || normalized.includes("token") || normalized.includes("secret") || normalized.includes("password");
|
|
314
|
-
}
|
|
315
105
|
function findCandidate(candidates, kind) {
|
|
316
106
|
return candidates.find((candidate) => candidate.kind === kind);
|
|
317
107
|
}
|
|
@@ -398,30 +188,6 @@ function normalizeExtensionCapabilities(capabilities = {}) {
|
|
|
398
188
|
}
|
|
399
189
|
|
|
400
190
|
// ../packages/timeline/dist/index.js
|
|
401
|
-
function createTimelineSequencer(options) {
|
|
402
|
-
let seq = options.startSeq ?? 0;
|
|
403
|
-
const now = options.now ?? Date.now;
|
|
404
|
-
return {
|
|
405
|
-
append(item, rawRef) {
|
|
406
|
-
seq += 1;
|
|
407
|
-
return appendTimelineItem({
|
|
408
|
-
sessionId: options.sessionId,
|
|
409
|
-
provider: options.provider,
|
|
410
|
-
epoch: options.epoch,
|
|
411
|
-
seq,
|
|
412
|
-
timestamp: now(),
|
|
413
|
-
item,
|
|
414
|
-
rawRef
|
|
415
|
-
});
|
|
416
|
-
}
|
|
417
|
-
};
|
|
418
|
-
}
|
|
419
|
-
function appendTimelineItem(envelope) {
|
|
420
|
-
return {
|
|
421
|
-
...envelope,
|
|
422
|
-
rawRef: envelope.rawRef ? { ...envelope.rawRef } : void 0
|
|
423
|
-
};
|
|
424
|
-
}
|
|
425
191
|
function createTimelineCursor(cursor) {
|
|
426
192
|
return {
|
|
427
193
|
epoch: cursor.epoch,
|
|
@@ -443,13 +209,6 @@ function fetchTimeline(timeline, request = {}) {
|
|
|
443
209
|
hasGap: firstSeq !== void 0 && firstSeq > cursor.afterSeq + 1
|
|
444
210
|
};
|
|
445
211
|
}
|
|
446
|
-
function mergeTimeline(existing, incoming) {
|
|
447
|
-
const byKey = /* @__PURE__ */ new Map();
|
|
448
|
-
for (const item of [...existing, ...incoming]) {
|
|
449
|
-
byKey.set(timelineKey(item), item);
|
|
450
|
-
}
|
|
451
|
-
return sortTimeline([...byKey.values()]);
|
|
452
|
-
}
|
|
453
212
|
function cursorFromTimelineStart(timeline) {
|
|
454
213
|
return {
|
|
455
214
|
epoch: timeline[0]?.epoch ?? "default",
|
|
@@ -462,9 +221,6 @@ function sortTimeline(timeline) {
|
|
|
462
221
|
return left.seq - right.seq;
|
|
463
222
|
});
|
|
464
223
|
}
|
|
465
|
-
function timelineKey(item) {
|
|
466
|
-
return `${item.epoch}:${item.seq}`;
|
|
467
|
-
}
|
|
468
224
|
|
|
469
225
|
// ../packages/client/dist/index.js
|
|
470
226
|
var FlitroHttpClient = class {
|
|
@@ -1438,9 +1194,7 @@ export {
|
|
|
1438
1194
|
FlitroFetchSseTimelineStream,
|
|
1439
1195
|
FlitroHttpClient,
|
|
1440
1196
|
FlitroSseTimelineStream,
|
|
1441
|
-
RUNTIME_KINDS,
|
|
1442
1197
|
WeftClient,
|
|
1443
|
-
appendTimelineItem,
|
|
1444
1198
|
createFlitroDriver,
|
|
1445
1199
|
createFlitroEmbedRuntime,
|
|
1446
1200
|
createFlitroProviderRuntime,
|
|
@@ -1448,18 +1202,5 @@ export {
|
|
|
1448
1202
|
createFlitroRuntimeCandidates,
|
|
1449
1203
|
createFlitroRuntimeCapabilityReport,
|
|
1450
1204
|
createFlitroTimelineStream,
|
|
1451
|
-
|
|
1452
|
-
createRuntimeExtensionContext,
|
|
1453
|
-
createTimelineCursor,
|
|
1454
|
-
createTimelineSequencer,
|
|
1455
|
-
fetchTimeline,
|
|
1456
|
-
initialRuntimeState,
|
|
1457
|
-
invokeSessionTool,
|
|
1458
|
-
mapCodexSandboxModeToSandboxPolicy,
|
|
1459
|
-
mapPermissionModeToCodexParams,
|
|
1460
|
-
mergeTimeline,
|
|
1461
|
-
probeFlitroCapabilities,
|
|
1462
|
-
reduceRuntimeState,
|
|
1463
|
-
sanitizeProviderSourceTools,
|
|
1464
|
-
selectRuntimeCandidate
|
|
1205
|
+
probeFlitroCapabilities
|
|
1465
1206
|
};
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|