@impulselab/hepha 0.2.400 → 0.2.402
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/index.js +176 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1878,6 +1878,8 @@ var HOST_TOOL_NAMES = {
|
|
|
1878
1878
|
SEND_TO_TASK: "send_to_task",
|
|
1879
1879
|
STOP_TASK: "stop_task",
|
|
1880
1880
|
PICKUP_TASK: "pickup_task",
|
|
1881
|
+
// A JS script whose agent() calls ARE platform tasks (docs/agents/workflows.md).
|
|
1882
|
+
WORKFLOW: "workflow",
|
|
1881
1883
|
// docs/integrations/database-access.md; detect is environment-setup only.
|
|
1882
1884
|
DATABASE_QUERY: "database_query",
|
|
1883
1885
|
DATABASE_WRITE: "database_write",
|
|
@@ -2245,6 +2247,179 @@ function describeAnnotateImage(record, state) {
|
|
|
2245
2247
|
);
|
|
2246
2248
|
}
|
|
2247
2249
|
|
|
2250
|
+
// ../../packages/core/src/source-scan/end-of-comment.ts
|
|
2251
|
+
function endOfComment(source, at) {
|
|
2252
|
+
if (source[at] !== "/") return at;
|
|
2253
|
+
if (source[at + 1] === "/") {
|
|
2254
|
+
const line = source.indexOf("\n", at);
|
|
2255
|
+
return line === -1 ? source.length : line - 1;
|
|
2256
|
+
}
|
|
2257
|
+
if (source[at + 1] === "*") {
|
|
2258
|
+
const block = source.indexOf("*/", at + 2);
|
|
2259
|
+
return block === -1 ? source.length : block + 1;
|
|
2260
|
+
}
|
|
2261
|
+
return at;
|
|
2262
|
+
}
|
|
2263
|
+
|
|
2264
|
+
// ../../packages/core/src/source-scan/end-of-string-literal.ts
|
|
2265
|
+
function endOfStringLiteral(source, open) {
|
|
2266
|
+
const quote = source[open];
|
|
2267
|
+
for (let at = open + 1; at < source.length; at += 1) {
|
|
2268
|
+
if (source[at] === "\\") at += 1;
|
|
2269
|
+
else if (source[at] === quote) return at;
|
|
2270
|
+
}
|
|
2271
|
+
return source.length;
|
|
2272
|
+
}
|
|
2273
|
+
|
|
2274
|
+
// ../../packages/core/src/source-scan/end-of-skippable.ts
|
|
2275
|
+
function endOfSkippable(source, at) {
|
|
2276
|
+
const char = source[at];
|
|
2277
|
+
if (char === "'" || char === '"' || char === "`") {
|
|
2278
|
+
return endOfStringLiteral(source, at);
|
|
2279
|
+
}
|
|
2280
|
+
return endOfComment(source, at);
|
|
2281
|
+
}
|
|
2282
|
+
|
|
2283
|
+
// ../../packages/core/src/source-scan/end-of-object-literal.ts
|
|
2284
|
+
function endOfObjectLiteral(source, open) {
|
|
2285
|
+
let depth = 0;
|
|
2286
|
+
for (let at = open; at < source.length; at += 1) {
|
|
2287
|
+
const skipped = endOfSkippable(source, at);
|
|
2288
|
+
if (skipped !== at) {
|
|
2289
|
+
at = skipped;
|
|
2290
|
+
continue;
|
|
2291
|
+
}
|
|
2292
|
+
if (source[at] === "{") depth += 1;
|
|
2293
|
+
else if (source[at] === "}" && (depth -= 1) === 0) return at + 1;
|
|
2294
|
+
}
|
|
2295
|
+
return -1;
|
|
2296
|
+
}
|
|
2297
|
+
|
|
2298
|
+
// ../../packages/core/src/source-scan/has-spread-in-code.ts
|
|
2299
|
+
function hasSpreadInCode(literal) {
|
|
2300
|
+
for (let at = 0; at < literal.length; at += 1) {
|
|
2301
|
+
const skipped = endOfSkippable(literal, at);
|
|
2302
|
+
if (skipped !== at) {
|
|
2303
|
+
at = skipped;
|
|
2304
|
+
continue;
|
|
2305
|
+
}
|
|
2306
|
+
if (literal.startsWith("...", at)) return true;
|
|
2307
|
+
}
|
|
2308
|
+
return false;
|
|
2309
|
+
}
|
|
2310
|
+
|
|
2311
|
+
// ../../packages/core/src/source-scan/meta-declaration-open.ts
|
|
2312
|
+
function metaDeclarationOpen(script) {
|
|
2313
|
+
const anchor = /export[ \t]+const[ \t]+meta[ \t]*=\s*\{/y;
|
|
2314
|
+
let at = 0;
|
|
2315
|
+
while (at < script.length) {
|
|
2316
|
+
if (/\s/.test(script[at] ?? "")) {
|
|
2317
|
+
at += 1;
|
|
2318
|
+
continue;
|
|
2319
|
+
}
|
|
2320
|
+
const comment = endOfComment(script, at);
|
|
2321
|
+
if (comment !== at) {
|
|
2322
|
+
at = comment + 1;
|
|
2323
|
+
continue;
|
|
2324
|
+
}
|
|
2325
|
+
anchor.lastIndex = at;
|
|
2326
|
+
return anchor.test(script) ? script.indexOf("{", at) : -1;
|
|
2327
|
+
}
|
|
2328
|
+
return -1;
|
|
2329
|
+
}
|
|
2330
|
+
|
|
2331
|
+
// ../../packages/core/src/source-scan/unescape-string-literal.ts
|
|
2332
|
+
function unescapeStringLiteral(body) {
|
|
2333
|
+
const single = {
|
|
2334
|
+
n: "\n",
|
|
2335
|
+
t: " ",
|
|
2336
|
+
r: "\r",
|
|
2337
|
+
b: "\b",
|
|
2338
|
+
f: "\f",
|
|
2339
|
+
v: "\v",
|
|
2340
|
+
"0": "\0"
|
|
2341
|
+
};
|
|
2342
|
+
return body.replace(
|
|
2343
|
+
/\\(u\{([0-9a-fA-F]+)\}|u([0-9a-fA-F]{4})|x([0-9a-fA-F]{2})|.)/gs,
|
|
2344
|
+
(_, escape, braced, unicode, hex) => {
|
|
2345
|
+
const code = braced ?? unicode ?? hex;
|
|
2346
|
+
if (code === void 0) return single[escape] ?? escape;
|
|
2347
|
+
const point = Number.parseInt(code, 16);
|
|
2348
|
+
return point <= 1114111 ? String.fromCodePoint(point) : `\\${escape}`;
|
|
2349
|
+
}
|
|
2350
|
+
);
|
|
2351
|
+
}
|
|
2352
|
+
|
|
2353
|
+
// ../../packages/core/src/source-scan/quoted-field-at.ts
|
|
2354
|
+
function quotedFieldAt(literal, at, field) {
|
|
2355
|
+
const key = /^(['"])?/.exec(literal.slice(at));
|
|
2356
|
+
const quoted = key?.[1] ?? "";
|
|
2357
|
+
const start = at + quoted.length;
|
|
2358
|
+
if (!literal.startsWith(field, start)) return void 0;
|
|
2359
|
+
if (!quoted && /[A-Za-z0-9_$]/.test(literal[at - 1] ?? "")) return void 0;
|
|
2360
|
+
const after = literal.slice(start + field.length);
|
|
2361
|
+
const opener = new RegExp(`^${quoted}\\s*:\\s*['"\`]`).exec(after);
|
|
2362
|
+
if (!opener) return void 0;
|
|
2363
|
+
const quote = start + field.length + opener[0].length - 1;
|
|
2364
|
+
const close = endOfStringLiteral(literal, quote);
|
|
2365
|
+
let tail = close + 1;
|
|
2366
|
+
for (; ; ) {
|
|
2367
|
+
while (/\s/.test(literal[tail] ?? "")) tail += 1;
|
|
2368
|
+
const skipped = endOfSkippable(literal, tail);
|
|
2369
|
+
if (skipped === tail) break;
|
|
2370
|
+
tail = skipped + 1;
|
|
2371
|
+
}
|
|
2372
|
+
if (literal[tail] !== "," && literal[tail] !== "}") return void 0;
|
|
2373
|
+
if (literal[quote] === "`" && /\$\{/.test(literal.slice(quote, close))) {
|
|
2374
|
+
return void 0;
|
|
2375
|
+
}
|
|
2376
|
+
return unescapeStringLiteral(literal.slice(quote + 1, close));
|
|
2377
|
+
}
|
|
2378
|
+
|
|
2379
|
+
// ../../packages/core/src/source-scan/top-level-string-field.ts
|
|
2380
|
+
function topLevelStringField(literal, field) {
|
|
2381
|
+
let depth = 0;
|
|
2382
|
+
let found;
|
|
2383
|
+
for (let at = 0; at < literal.length; at += 1) {
|
|
2384
|
+
if (depth === 1) {
|
|
2385
|
+
const value = quotedFieldAt(literal, at, field);
|
|
2386
|
+
if (value !== void 0) found = value;
|
|
2387
|
+
}
|
|
2388
|
+
const skipped = endOfSkippable(literal, at);
|
|
2389
|
+
if (skipped !== at) {
|
|
2390
|
+
at = skipped;
|
|
2391
|
+
continue;
|
|
2392
|
+
}
|
|
2393
|
+
const char = literal[at];
|
|
2394
|
+
if (char === "{" || char === "[") depth += 1;
|
|
2395
|
+
else if (char === "}" || char === "]") depth -= 1;
|
|
2396
|
+
}
|
|
2397
|
+
return found;
|
|
2398
|
+
}
|
|
2399
|
+
|
|
2400
|
+
// ../../packages/core/src/source-scan/meta-name-in-script.ts
|
|
2401
|
+
function metaNameInScript(script) {
|
|
2402
|
+
const open = metaDeclarationOpen(script);
|
|
2403
|
+
if (open === -1) return void 0;
|
|
2404
|
+
const end = endOfObjectLiteral(script, open);
|
|
2405
|
+
if (end === -1) return void 0;
|
|
2406
|
+
const literal = script.slice(open, end);
|
|
2407
|
+
if (hasSpreadInCode(literal)) return void 0;
|
|
2408
|
+
const name = topLevelStringField(literal, "name");
|
|
2409
|
+
return name?.trim() && topLevelStringField(literal, "description")?.trim() ? name.slice(0, 80) : void 0;
|
|
2410
|
+
}
|
|
2411
|
+
|
|
2412
|
+
// ../../packages/agents/src/tool-activity/canonical/workflow-script-name.ts
|
|
2413
|
+
function workflowScriptName(script) {
|
|
2414
|
+
return metaNameInScript(script);
|
|
2415
|
+
}
|
|
2416
|
+
|
|
2417
|
+
// ../../packages/agents/src/tool-activity/canonical/describe-workflow.ts
|
|
2418
|
+
function describeWorkflow(record) {
|
|
2419
|
+
const name = workflowScriptName(toolInput.str(record.script) ?? "");
|
|
2420
|
+
return labelOnly(name ? `Ran workflow "${name}"` : "Ran a workflow");
|
|
2421
|
+
}
|
|
2422
|
+
|
|
2248
2423
|
// ../../packages/agents/src/tool-activity/capture/describe-attach-image.ts
|
|
2249
2424
|
function describeAttachImage(record, state) {
|
|
2250
2425
|
const file = toolActivityBasename(toolInput.str(record.path));
|
|
@@ -2569,6 +2744,7 @@ var canonicalToolActivityDescribers = new Map([
|
|
|
2569
2744
|
}
|
|
2570
2745
|
],
|
|
2571
2746
|
[HOST_TOOL_NAMES.LIST_TASKS, () => labelOnly("Listed the team tasks")],
|
|
2747
|
+
[HOST_TOOL_NAMES.WORKFLOW, describeWorkflow],
|
|
2572
2748
|
[HOST_TOOL_NAMES.PICKUP_TASK, () => labelOnly("Picked up a team task")],
|
|
2573
2749
|
[
|
|
2574
2750
|
HOST_TOOL_NAMES.UPDATE_TASK,
|