@parcha/agentrun-serve 0.1.0-beta.61 → 0.1.0-beta.62
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/CHANGELOG.md +66 -0
- package/README.md +102 -13
- package/dist/api-only.d.ts +4 -0
- package/dist/api-only.js +5 -1
- package/dist/archil-settings.d.ts +9 -0
- package/dist/archil-settings.js +8 -1
- package/dist/bash-read-only.d.ts +3 -0
- package/dist/bash-read-only.js +6 -3
- package/dist/chatgpt-plan.d.ts +26 -8
- package/dist/chatgpt-plan.js +89 -21
- package/dist/claude-login.d.ts +12 -5
- package/dist/claude-login.js +28 -3
- package/dist/cli.js +19 -8
- package/dist/composio-triggers.d.ts +9 -3
- package/dist/computers.d.ts +3 -0
- package/dist/computers.js +2 -1
- package/dist/console/assets/{backend-C9ffXUR5.js → backend-DEgVn5lC.js} +1 -1
- package/dist/console/assets/index-CG5tELph.js +639 -0
- package/dist/console/assets/share-CIeFK2Oe.js +6 -0
- package/dist/console/assets/{styles-fjQBFfMv.css → styles-D0SufbzK.css} +1 -1
- package/dist/console/index.html +3 -3
- package/dist/console/share.html +3 -3
- package/dist/cut-pool.d.ts +14 -0
- package/dist/cut-pool.js +98 -0
- package/dist/cut-worker.d.ts +14 -0
- package/dist/cut-worker.js +16 -0
- package/dist/decisions.d.ts +4 -0
- package/dist/decisions.js +9 -1
- package/dist/env-switch.d.ts +3 -0
- package/dist/env-switch.js +3 -0
- package/dist/harness-table.d.ts +7 -0
- package/dist/harness-table.js +6 -3
- package/dist/import.d.ts +8 -1
- package/dist/import.js +36 -5
- package/dist/key-check.js +22 -8
- package/dist/learned-nodes.d.ts +2 -1
- package/dist/learned-nodes.js +2 -1
- package/dist/mcp-gateway.d.ts +24 -0
- package/dist/mcp-gateway.js +97 -8
- package/dist/mcp-servers-store.d.ts +7 -10
- package/dist/mcp-servers-store.js +15 -9
- package/dist/native/cli.js +5 -1
- package/dist/ollama-provider.d.ts +10 -3
- package/dist/ollama-provider.js +17 -7
- package/dist/openapi.js +29 -12
- package/dist/otel/tracer.d.ts +6 -3
- package/dist/otel/tracer.js +24 -6
- package/dist/page.d.ts +7 -0
- package/dist/page.js +17 -4
- package/dist/place.d.ts +25 -9
- package/dist/place.js +37 -11
- package/dist/print.d.ts +3 -2
- package/dist/print.js +8 -6
- package/dist/run-launch.js +16 -3
- package/dist/run-model-key.d.ts +2 -1
- package/dist/run-model-key.js +2 -1
- package/dist/run-reads-over-store.d.ts +7 -0
- package/dist/run-reads-over-store.js +32 -4
- package/dist/runnable.d.ts +6 -3
- package/dist/runnable.js +16 -6
- package/dist/runner/adapter-loop.js +64 -25
- package/dist/runner/adapter-run-spec.d.ts +6 -1
- package/dist/runner/adapter-run-spec.js +14 -11
- package/dist/runner/adapters/index.d.ts +4 -0
- package/dist/runner/adapters/index.js +2 -1
- package/dist/runner/claim-secrets.d.ts +3 -1
- package/dist/runner/claim-secrets.js +18 -7
- package/dist/runner/cli-run-spec.js +12 -8
- package/dist/runner/dispatch.js +2 -0
- package/dist/runner/harness-loops.d.ts +5 -0
- package/dist/runner/harness-loops.js +4 -1
- package/dist/runner/live-ticker.js +3 -1
- package/dist/runner/loop-contract.d.ts +4 -1
- package/dist/runner/mcp-run.d.ts +5 -0
- package/dist/runner/mcp-run.js +18 -0
- package/dist/runner/meta-tools.js +4 -4
- package/dist/runner/metrics.d.ts +4 -2
- package/dist/runner/metrics.js +5 -3
- package/dist/runner/native-loop.js +2 -2
- package/dist/runner/run-child-host.d.ts +10 -6
- package/dist/runner/run-child-host.js +44 -29
- package/dist/runner/run-child.js +1 -0
- package/dist/runner/runner.js +2 -0
- package/dist/runner/workflow-calls.d.ts +4 -3
- package/dist/runner/workflow-calls.js +41 -12
- package/dist/runner/workflow-spec.js +1 -1
- package/dist/secret-rules.d.ts +0 -1
- package/dist/secret-rules.js +25 -5
- package/dist/server.d.ts +10 -1
- package/dist/server.js +114 -38
- package/dist/share-host.d.ts +111 -0
- package/dist/share-host.js +666 -0
- package/dist/store-reads/analytics.d.ts +15 -0
- package/dist/store-reads/analytics.js +17 -0
- package/dist/suggestions.js +32 -3
- package/dist/templates.d.ts +3 -1
- package/dist/templates.js +7 -3
- package/dist/tool-gate.d.ts +25 -9
- package/dist/tool-gate.js +58 -19
- package/dist/tool-plane.d.ts +1 -0
- package/dist/tool-plane.js +6 -2
- package/dist/trigger-composio.js +1 -1
- package/dist/webhooks.d.ts +3 -0
- package/dist/webhooks.js +5 -0
- package/dist/workspace/archil-claim.d.ts +7 -3
- package/dist/workspace/archil-claim.js +13 -5
- package/dist/workspace/archil-mount-credential.d.ts +6 -0
- package/dist/workspace/archil-mount-credential.js +11 -0
- package/dist/workspace/computer-deps.d.ts +5 -3
- package/dist/workspace/computer-deps.js +11 -9
- package/dist/workspace/computer-for-claim.d.ts +6 -2
- package/dist/workspace/computer-for-claim.js +43 -12
- package/dist/workspace/computer-janitor.d.ts +7 -4
- package/dist/workspace/computer-janitor.js +7 -4
- package/dist/workspace/computer-kept.d.ts +7 -1
- package/dist/workspace/computer-kept.js +7 -1
- package/dist/workspace/kind-skills/desktop/SKILL.md +12 -3
- package/dist/workspace/mount-revoke-left.d.ts +16 -4
- package/dist/workspace/mount-revoke-left.js +42 -22
- package/dist/workspace/resolve-computer.d.ts +11 -5
- package/dist/workspace/resolve-computer.js +22 -13
- package/dist/workspace/run-end-computers.js +1 -1
- package/dist/workspace/run-tools.d.ts +10 -3
- package/dist/workspace/run-tools.js +5 -4
- package/dist/wrapped.d.ts +29 -2
- package/dist/wrapped.js +20 -3
- package/launcher/agentrun-serve +1 -1
- package/package.json +12 -12
- package/dist/console/assets/index-BnZV3lvW.js +0 -639
- package/dist/console/assets/share-B1o5mJ56.js +0 -6
- /package/dist/console/assets/{styles-D_znYrHR.js → styles-BGZxYkky.js} +0 -0
package/dist/chatgpt-plan.js
CHANGED
|
@@ -206,6 +206,8 @@ export class ChatGPTPlan {
|
|
|
206
206
|
#failedChanges = 0;
|
|
207
207
|
/** The server's read in flight (refresh), which a read while it is out waits for. */
|
|
208
208
|
#refreshing;
|
|
209
|
+
/** The last settle queued (settle): each waits for the one before it. */
|
|
210
|
+
#settling;
|
|
209
211
|
/** The ends of the sign-ins cancelled and not yet ended (close waits for them). */
|
|
210
212
|
#ending = new Set();
|
|
211
213
|
#watchers = new Set();
|
|
@@ -275,13 +277,16 @@ export class ChatGPTPlan {
|
|
|
275
277
|
this.#snapshot = row;
|
|
276
278
|
this.#writes += 1;
|
|
277
279
|
}
|
|
278
|
-
/** The row sealed as `bytes`, opened (its tokens held for redaction); none when they
|
|
280
|
+
/** The row sealed as `bytes`, opened (its tokens held for redaction, and those of each pair it carries); none when they
|
|
281
|
+
* do not open. */
|
|
279
282
|
open(bytes) {
|
|
280
283
|
try {
|
|
281
284
|
const row = JSON.parse(unsealColumn(this.#deps.sealKey, sealedAt.sealedKey(CHATGPT_PLAN_ROW), bytes).toString("utf8"));
|
|
282
285
|
if (row?.v !== 1 || !row.credential?.access || !row.credential.refresh)
|
|
283
286
|
return undefined;
|
|
284
287
|
this.hold(row.credential);
|
|
288
|
+
for (const old of row.retired ?? [])
|
|
289
|
+
this.hold(old);
|
|
285
290
|
return row;
|
|
286
291
|
}
|
|
287
292
|
catch {
|
|
@@ -298,11 +303,19 @@ export class ChatGPTPlan {
|
|
|
298
303
|
const bytes = this.seal(row);
|
|
299
304
|
return (await this.#deps.store.sealedKeys.replaceIf(CHATGPT_PLAN_ROW, was, bytes)) ? bytes : undefined;
|
|
300
305
|
}
|
|
301
|
-
/** Reads the sealed row into the state a reader sees. Returns this. */
|
|
306
|
+
/** Reads the sealed row into the state a reader sees. Returns this. A read never settles (settleLeft). */
|
|
302
307
|
async load() {
|
|
303
308
|
await this.readTaken();
|
|
304
309
|
return this;
|
|
305
310
|
}
|
|
311
|
+
/** What a stop left in the row (a sign-in it cut off after its save: keep) settled, out of the caller's way: the
|
|
312
|
+
* server's, once, at its start, once its first offers are made. Models it lists are told to the server (its change
|
|
313
|
+
* callback, as a sign-in's are), so the offers made from the fallback list are made again. A runner's reader
|
|
314
|
+
* (planReaderOf, at each claim) never calls it, so no runner lists the plan's models or sends a refresh token to
|
|
315
|
+
* OpenAI's revocation endpoint. */
|
|
316
|
+
settleLeft() {
|
|
317
|
+
void this.settle().then(({ listed }) => (listed ? this.tellChanged() : undefined));
|
|
318
|
+
}
|
|
306
319
|
view() {
|
|
307
320
|
if (this.#pending && this.#pending.expiresAt <= this.now())
|
|
308
321
|
this.expire();
|
|
@@ -456,16 +469,16 @@ export class ChatGPTPlan {
|
|
|
456
469
|
return this.view();
|
|
457
470
|
}
|
|
458
471
|
/** A credential from the sign-in started at `epoch`, checked and sealed with what a view shows. A sign-out or a newer
|
|
459
|
-
* sign-in since then wins: the credential is dropped, never written, and revoked at OpenAI.
|
|
460
|
-
*
|
|
461
|
-
*
|
|
472
|
+
* sign-in since then wins: the credential is dropped, never written, and revoked at OpenAI. It is saved before anything
|
|
473
|
+
* slow, so a stop that cuts it off never leaves its pair live at OpenAI and saved nowhere: a sign-in it takes the place
|
|
474
|
+
* of rides in the row (`retired`, with any it carried) until it is revoked, and its models are listed after (settle).
|
|
475
|
+
* The row is replaced only while it still holds what was read (a renewal that wrote back meanwhile is read and carried
|
|
476
|
+
* in turn), so no earlier pair is left alive and unsaved. */
|
|
462
477
|
async keep(credential, epoch, saved) {
|
|
463
478
|
if (credential.scopes && !credential.scopes.includes(DIRECT_SCOPE))
|
|
464
479
|
throw new Error(`the grant did not include ${DIRECT_SCOPE}`);
|
|
465
480
|
this.hold(credential);
|
|
466
|
-
|
|
467
|
-
const row = { v: 1, state: "signed_in", credential, ...whoOf(credential.access), models };
|
|
468
|
-
let previousRevoked;
|
|
481
|
+
let row;
|
|
469
482
|
for (;;) {
|
|
470
483
|
if (epoch !== this.#epoch) {
|
|
471
484
|
if (!(await this.revoke(credential)))
|
|
@@ -473,27 +486,76 @@ export class ChatGPTPlan {
|
|
|
473
486
|
return;
|
|
474
487
|
}
|
|
475
488
|
const was = await this.#deps.store.sealedKeys.get(CHATGPT_PLAN_ROW);
|
|
489
|
+
const previous = was === undefined ? undefined : this.open(was);
|
|
490
|
+
const retired = [...(previous?.retired ?? []), ...(previous && previous.credential.refresh !== credential.refresh ? [previous.credential] : [])];
|
|
491
|
+
row = { v: 1, state: "signed_in", credential, ...whoOf(credential.access), models: [...PLAN_FALLBACK_MODELS], unlisted: true, ...(retired.length ? { retired } : {}) };
|
|
492
|
+
if (epoch !== this.#epoch)
|
|
493
|
+
continue;
|
|
476
494
|
if (was === undefined) {
|
|
477
495
|
// No row to compare against: only the server signs in, and nothing else makes the row (a runner's renewal
|
|
478
496
|
// replaces one only while it holds its lease), so a plain write.
|
|
479
497
|
await putSealedKey(this.#deps.store, this.#deps.sealKey, CHATGPT_PLAN_ROW, JSON.stringify(row));
|
|
480
498
|
break;
|
|
481
499
|
}
|
|
482
|
-
const previous = this.open(was);
|
|
483
|
-
if (previous && previous.credential.refresh !== credential.refresh)
|
|
484
|
-
previousRevoked = await this.revoke(previous.credential);
|
|
485
|
-
if (epoch !== this.#epoch)
|
|
486
|
-
continue;
|
|
487
500
|
if (await this.swap(was, row))
|
|
488
501
|
break;
|
|
489
502
|
}
|
|
490
503
|
this.wrote(row);
|
|
491
504
|
this.#problem = undefined;
|
|
492
|
-
this.#deps.log?.({ chatgpt: "signed_in"
|
|
493
|
-
// Saved: no longer waiting, so it reads signed in while the server takes the change (`saved`, the
|
|
505
|
+
this.#deps.log?.({ chatgpt: "signed_in" });
|
|
506
|
+
// Saved: no longer waiting, so it reads signed in while it settles and the server takes the change (`saved`, the
|
|
507
|
+
// sign-in's settle).
|
|
494
508
|
saved?.();
|
|
509
|
+
const { revoked: previousRevoked } = await this.settle();
|
|
510
|
+
if (previousRevoked !== undefined)
|
|
511
|
+
this.#deps.log?.({ chatgpt: "previous_revoked", revoked: String(previousRevoked) });
|
|
495
512
|
await this.tellChanged();
|
|
496
513
|
}
|
|
514
|
+
/** What a saved sign-in leaves (keep), done: its models listed (`unlisted`), and each pair it carries (`retired`)
|
|
515
|
+
* revoked at OpenAI and dropped from the row once OpenAI confirms it. `revoked`: whether every carried pair was
|
|
516
|
+
* confirmed, none when the row carried none; `listed`: whether it wrote the models OpenAI listed. The server's alone,
|
|
517
|
+
* one at a time: only a sign-in (keep) and the server's start (settleLeft) settle, and a runner does neither. The row
|
|
518
|
+
* is written only while it holds what was read and no renewal's lease is live (a renewal writes back over the row it
|
|
519
|
+
* leased, and carries these fields); what is left stays for the server's next start. Never throws. */
|
|
520
|
+
settle() {
|
|
521
|
+
const run = (this.#settling ?? Promise.resolve({})).then(() => this.settleOnce()).catch(() => ({}));
|
|
522
|
+
this.#settling = run;
|
|
523
|
+
void run.then(() => (this.#settling === run ? (this.#settling = undefined) : undefined));
|
|
524
|
+
return run;
|
|
525
|
+
}
|
|
526
|
+
async settleOnce() {
|
|
527
|
+
const read = await this.readSealed();
|
|
528
|
+
if (!read || (!read.row.unlisted && !read.row.retired?.length))
|
|
529
|
+
return {};
|
|
530
|
+
const signedIn = read.row.credential.refresh;
|
|
531
|
+
const models = read.row.unlisted && read.row.state === "signed_in" ? await this.listModels(read.row.credential.access) : undefined;
|
|
532
|
+
const confirmed = new Set();
|
|
533
|
+
for (const old of read.row.retired ?? [])
|
|
534
|
+
if (await this.revoke(old))
|
|
535
|
+
confirmed.add(old.refresh);
|
|
536
|
+
const revoked = read.row.retired?.length ? confirmed.size === read.row.retired.length : undefined;
|
|
537
|
+
const done = revoked === undefined ? {} : { revoked };
|
|
538
|
+
for (;;) {
|
|
539
|
+
const now = await this.readSealed();
|
|
540
|
+
// Signed out meanwhile: the sign-out revoked what the row held.
|
|
541
|
+
if (!now)
|
|
542
|
+
return done;
|
|
543
|
+
if (now.row.lease && now.row.lease.until > (await this.storeNow()))
|
|
544
|
+
return done;
|
|
545
|
+
const { unlisted, retired: carried, ...rest } = now.row;
|
|
546
|
+
const retired = (carried ?? []).filter((old) => !confirmed.has(old.refresh));
|
|
547
|
+
// The models listed are this sign-in's: a newer sign-in's row lists its own.
|
|
548
|
+
const listed = Boolean(unlisted && models && now.row.credential.refresh === signedIn);
|
|
549
|
+
const next = { ...rest, ...(listed && models ? { models } : unlisted ? { unlisted } : {}), ...(retired.length ? { retired } : {}) };
|
|
550
|
+
if (!listed && retired.length === (carried ?? []).length)
|
|
551
|
+
return done;
|
|
552
|
+
const bytes = await this.swap(now.bytes, next);
|
|
553
|
+
if (bytes) {
|
|
554
|
+
this.wrote(next);
|
|
555
|
+
return { ...done, listed };
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
}
|
|
497
559
|
/** Tells the server the sign-in changed (its change callback: env read again, the listings relisted, the offers
|
|
498
560
|
* probed). What the server does with it is not the change's to fail: a failure is owed, said in the log (once: not
|
|
499
561
|
* again for `again`, a retry of one owed), and taken again at the server's next read (refresh). */
|
|
@@ -528,19 +590,19 @@ export class ChatGPTPlan {
|
|
|
528
590
|
await this.tellChanged(true);
|
|
529
591
|
})().finally(() => (this.#refreshing = undefined)));
|
|
530
592
|
}
|
|
531
|
-
/** The plan's models from OpenAI's list (GET /v1/models with the token), those of the current families
|
|
532
|
-
* list when it can't be read
|
|
593
|
+
/** The plan's models from OpenAI's list (GET /v1/models with the token), those of the current families (the fallback
|
|
594
|
+
* list when it names none); none when the list can't be read, so the row stays `unlisted`. */
|
|
533
595
|
async listModels(token) {
|
|
534
596
|
try {
|
|
535
597
|
const response = await fetch(`${PLAN_ORIGIN}/v1/models`, { headers: { authorization: `Bearer ${token}` }, signal: AbortSignal.timeout(5_000) });
|
|
536
598
|
if (!response.ok)
|
|
537
|
-
return
|
|
599
|
+
return undefined;
|
|
538
600
|
const body = (await response.json());
|
|
539
601
|
const ids = (body.data ?? []).map((model) => model.id).filter((id) => typeof id === "string" && /^gpt-6(?:[.-]|$)/.test(id));
|
|
540
602
|
return ids.length ? [...new Set(ids)] : [...PLAN_FALLBACK_MODELS];
|
|
541
603
|
}
|
|
542
604
|
catch {
|
|
543
|
-
return
|
|
605
|
+
return undefined;
|
|
544
606
|
}
|
|
545
607
|
}
|
|
546
608
|
/** The access token to send now: the sealed one, renewed first when it ends within 5 minutes. Throws PlanUnavailable,
|
|
@@ -686,7 +748,11 @@ export class ChatGPTPlan {
|
|
|
686
748
|
continue;
|
|
687
749
|
// A row that does not open (sealed under another key) is removed, its tokens beyond reach to revoke.
|
|
688
750
|
const removed = row ? (await this.revoke(row.credential)) && !renewing : false;
|
|
689
|
-
|
|
751
|
+
// The pairs of the sign-ins it replaced that it still carries (keep, settle) go with it.
|
|
752
|
+
let carried = true;
|
|
753
|
+
for (const old of row?.retired ?? [])
|
|
754
|
+
carried = (await this.revoke(old)) && carried;
|
|
755
|
+
revoked = revoked && removed && carried;
|
|
690
756
|
break;
|
|
691
757
|
}
|
|
692
758
|
this.wrote(undefined);
|
|
@@ -714,7 +780,9 @@ export class ChatGPTPlan {
|
|
|
714
780
|
* sign-out or its 10 minutes) has ended, whatever its end said in the log. */
|
|
715
781
|
close() {
|
|
716
782
|
this.cancel();
|
|
717
|
-
|
|
783
|
+
// A settle out (the start's, a kept sign-in's) is waited for too: the server's stop bounds the wait (planClosed), and
|
|
784
|
+
// what it cuts off stays in the row for the next start.
|
|
785
|
+
return Promise.all([...this.#ending, this.#settling]).then(() => undefined);
|
|
718
786
|
}
|
|
719
787
|
}
|
|
720
788
|
/** For a run on a plan model (`model`, the one its claim chose): the plan's token read once before anything starts, so a
|
package/dist/claude-login.d.ts
CHANGED
|
@@ -278,15 +278,19 @@ export declare const LOGIN_SIGN_OUT_UNCONFIRMED: string;
|
|
|
278
278
|
/** What a sign-out answers beside `confirmed: false` where the CLI's step threw (`failed`, the error's words): the login is
|
|
279
279
|
* gone here all the same, and the CLI's own copy may remain. */
|
|
280
280
|
export declare const signOutCliFailed: (failed: string) => string;
|
|
281
|
+
/** What a sign-out answers beside `confirmed: false` where the CLI confirmed its own sign-out and every removal landed,
|
|
282
|
+
* but that older Keychain item, of the service `service`, may remain (keychainLeftover). */
|
|
283
|
+
export declare const signOutKeychainLeftover: (service: string | undefined) => string;
|
|
281
284
|
/** What a sign-out answers beside `confirmed: false` where some of the login is still there (`left`: each thing, its path
|
|
282
285
|
* and why), and the Keychain's words too where the CLI didn't confirm its own sign-out (`keychain`), naming the CLI
|
|
283
286
|
* step's failure where it threw (`failed`). */
|
|
284
287
|
export declare const signOutLeft: (left: readonly string[], keychain: boolean, failed?: string) => string;
|
|
285
288
|
/** Why a sign-out of this machine's own login (`folder`, the person's `~/.claude` or CLAUDE_CONFIG_DIR) is refused. */
|
|
286
289
|
export declare const machineSignOutRefused: (folder: string) => string;
|
|
287
|
-
/** POST /settings/claude-login/sign-out's answer: whether all of the login is gone (the CLI confirmed its own sign-out
|
|
288
|
-
* every removal landed, whether or not a folder was there
|
|
289
|
-
*
|
|
290
|
+
/** POST /settings/claude-login/sign-out's answer: whether all of the login is gone (the CLI confirmed its own sign-out,
|
|
291
|
+
* every removal landed, whether or not a folder was there, and the harness found no older Keychain item left under
|
|
292
|
+
* "unknown"), else words saying what may remain (LOGIN_SIGN_OUT_UNCONFIRMED, signOutLeft, signOutKeychainLeftover),
|
|
293
|
+
* and the view after it (`off`). */
|
|
290
294
|
export type ClaudeLoginSignOut = {
|
|
291
295
|
confirmed: boolean;
|
|
292
296
|
message?: string;
|
|
@@ -304,7 +308,10 @@ export type ClaudeLoginSignOut = {
|
|
|
304
308
|
* (claude-login-token.ts forgetLoginTokens). Each removal stands alone: one that fails is named in the answer
|
|
305
309
|
* (signOutLeft, `confirmed` false), and the others, the reader's drop and the server's reread of the keys still happen.
|
|
306
310
|
* So with the CLI's step: a throw finding the CLI or loading the harness is named in the answer (signOutCliFailed), and
|
|
307
|
-
* every removal still runs.
|
|
311
|
+
* every removal still runs. On macOS the harness's sign-out also deletes the older Keychain item a sign-in left under
|
|
312
|
+
* "unknown", which holds a refresh token, and says whether it went: where it may remain, the answer is not confirmed
|
|
313
|
+
* and its words say how to delete that item alone, named by its exact service (the harness's claudeKeychainService),
|
|
314
|
+
* in Keychain Access or with one `security` command (signOutKeychainLeftover, or after the other words).
|
|
308
315
|
* Where the folder is a link (put there after the turn-on, which refuses one), the link alone is removed, with the
|
|
309
316
|
* login's signed-in note: no CLI runs through it, nothing it leads to is touched, and the answer names it. Runs already going are left as a turn-off
|
|
310
317
|
* leaves them: each keeps the token its CLI holds, and fails in
|
|
@@ -329,7 +336,7 @@ export declare function startLoginHere(deps: ClaudeLoginDeps): Promise<ClaudeLog
|
|
|
329
336
|
* every change of the setting is. */
|
|
330
337
|
export declare function dropRefusedLogin(signIns: Pick<ClaudeSignIns, "serial">, settings: Pick<Settings, "get" | "remove">, why: string | undefined, env: Readonly<Record<string, string | undefined>>, log: (line: string) => void): Promise<void>;
|
|
331
338
|
/** What the routes and a run's check use of the harness (its login.ts), loaded only when asked. */
|
|
332
|
-
export type ClaudeLoginCli = Pick<typeof import("@parcha/agentrun-harness-claude"), "claudeLoginStatus" | "startClaudeLogin" | "claudeLoginCommand" | "claudeLogout">;
|
|
339
|
+
export type ClaudeLoginCli = Pick<typeof import("@parcha/agentrun-harness-claude"), "claudeLoginStatus" | "startClaudeLogin" | "claudeLoginCommand" | "claudeLogout" | "claudeKeychainService">;
|
|
333
340
|
/** How long a signed-in answer stands in for a check that gives none (loginBeforeRun). */
|
|
334
341
|
export declare const LOGIN_ANSWER_STANDS_MS: number;
|
|
335
342
|
/** The folder in the data folder that holds, per login, when it last answered signed in (noteAnswer). The server and its
|
package/dist/claude-login.js
CHANGED
|
@@ -756,6 +756,16 @@ export const LOGIN_SIGN_OUT_UNCONFIRMED = `Signed out here: AgentRun's copy of t
|
|
|
756
756
|
/** What a sign-out answers beside `confirmed: false` where the CLI's step threw (`failed`, the error's words): the login is
|
|
757
757
|
* gone here all the same, and the CLI's own copy may remain. */
|
|
758
758
|
export const signOutCliFailed = (failed) => `Signed out here: AgentRun's copy of the login is removed. ${keychainWords(failed)}`;
|
|
759
|
+
/** What may remain where the harness's sign-out could not delete the Keychain item a sign-in left under the account
|
|
760
|
+
* "unknown" at AgentRun's own folder (its claudeLogout's `leftoverGone` false), and how to delete that item alone by
|
|
761
|
+
* hand: by its exact service (`service`, the harness's claudeKeychainService for the folder, a hash of it with no path
|
|
762
|
+
* in it), never the bare "Claude Code-credentials", which the person's own CLI's item has, under "unknown" too where it
|
|
763
|
+
* ran with no USER. With no service (none for the folder, where the harness has nothing to drop) the words give no way
|
|
764
|
+
* to delete it, rather than one that may point at another login's item. */
|
|
765
|
+
const keychainLeftover = (service) => `On macOS an older Keychain item of this login, which holds a refresh token, could not be removed${service === undefined ? "." : `: in Keychain Access, search "${service}" and delete the item whose account is "unknown", or run \`security delete-generic-password -a unknown -s "${service}"\` in a terminal.`}`;
|
|
766
|
+
/** What a sign-out answers beside `confirmed: false` where the CLI confirmed its own sign-out and every removal landed,
|
|
767
|
+
* but that older Keychain item, of the service `service`, may remain (keychainLeftover). */
|
|
768
|
+
export const signOutKeychainLeftover = (service) => `Signed out here: AgentRun's copy of the login is removed. ${keychainLeftover(service)}`;
|
|
759
769
|
/** What a sign-out answers beside `confirmed: false` where some of the login is still there (`left`: each thing, its path
|
|
760
770
|
* and why), and the Keychain's words too where the CLI didn't confirm its own sign-out (`keychain`), naming the CLI
|
|
761
771
|
* step's failure where it threw (`failed`). */
|
|
@@ -774,7 +784,10 @@ export const machineSignOutRefused = (folder) => `This is your own Claude Code l
|
|
|
774
784
|
* (claude-login-token.ts forgetLoginTokens). Each removal stands alone: one that fails is named in the answer
|
|
775
785
|
* (signOutLeft, `confirmed` false), and the others, the reader's drop and the server's reread of the keys still happen.
|
|
776
786
|
* So with the CLI's step: a throw finding the CLI or loading the harness is named in the answer (signOutCliFailed), and
|
|
777
|
-
* every removal still runs.
|
|
787
|
+
* every removal still runs. On macOS the harness's sign-out also deletes the older Keychain item a sign-in left under
|
|
788
|
+
* "unknown", which holds a refresh token, and says whether it went: where it may remain, the answer is not confirmed
|
|
789
|
+
* and its words say how to delete that item alone, named by its exact service (the harness's claudeKeychainService),
|
|
790
|
+
* in Keychain Access or with one `security` command (signOutKeychainLeftover, or after the other words).
|
|
778
791
|
* Where the folder is a link (put there after the turn-on, which refuses one), the link alone is removed, with the
|
|
779
792
|
* login's signed-in note: no CLI runs through it, nothing it leads to is touched, and the answer names it. Runs already going are left as a turn-off
|
|
780
793
|
* leaves them: each keeps the token its CLI holds, and fails in
|
|
@@ -787,6 +800,8 @@ export const machineSignOutRefused = (folder) => `This is your own Claude Code l
|
|
|
787
800
|
export async function signOutClaudeLogin(deps) {
|
|
788
801
|
let off = false;
|
|
789
802
|
let signedOut = true;
|
|
803
|
+
let leftoverGone = true;
|
|
804
|
+
let leftoverService;
|
|
790
805
|
let cliFailed;
|
|
791
806
|
const left = [];
|
|
792
807
|
const remove = (what, path, options) => {
|
|
@@ -823,7 +838,15 @@ export async function signOutClaudeLogin(deps) {
|
|
|
823
838
|
try {
|
|
824
839
|
const { login } = loginAt("agentrun", deps.data, deps.env, deps.uid);
|
|
825
840
|
const cli = loginCli(await deps.pinned(), deps.env);
|
|
826
|
-
|
|
841
|
+
if (login && cli) {
|
|
842
|
+
const claude = await deps.claude();
|
|
843
|
+
({ signedOut, leftoverGone } = await claude.claudeLogout(cli, login, pathOf(deps.env)));
|
|
844
|
+
// The service the harness's drop deleted by, so the words name the item alone.
|
|
845
|
+
if (!leftoverGone)
|
|
846
|
+
leftoverService = claude.claudeKeychainService(login);
|
|
847
|
+
}
|
|
848
|
+
else
|
|
849
|
+
signedOut = false;
|
|
827
850
|
}
|
|
828
851
|
catch (error) {
|
|
829
852
|
signedOut = false;
|
|
@@ -851,7 +874,9 @@ export async function signOutClaudeLogin(deps) {
|
|
|
851
874
|
if (off)
|
|
852
875
|
await deps.changed();
|
|
853
876
|
}
|
|
854
|
-
const
|
|
877
|
+
const words = left.length > 0 ? signOutLeft(left, !signedOut, cliFailed) : signedOut ? undefined : cliFailed !== undefined ? signOutCliFailed(cliFailed) : LOGIN_SIGN_OUT_UNCONFIRMED;
|
|
878
|
+
// The older Keychain item the harness could not delete is said after the rest, or alone where nothing else remains.
|
|
879
|
+
const message = leftoverGone ? words : words === undefined ? signOutKeychainLeftover(leftoverService) : `${words} ${keychainLeftover(leftoverService)}`;
|
|
855
880
|
return { confirmed: message === undefined, ...(message ? { message } : {}), login: await claudeLoginView(deps) };
|
|
856
881
|
}
|
|
857
882
|
/** POST /settings/claude-login/login: the CLI's own sign-in, started on this machine, where it opens a browser, with the
|
package/dist/cli.js
CHANGED
|
@@ -14,7 +14,7 @@ import { REPEAT_MS, stopOnce, stopOnSignals } from "./stop-signals.js";
|
|
|
14
14
|
import { resetPassword } from "./owner.js";
|
|
15
15
|
import { banner } from "./print.js";
|
|
16
16
|
import { parseTokens } from "./api-token.js";
|
|
17
|
-
import { API_ONLY_ENV, API_ONLY_MCP_ORIGINS_ENV, apiOnlyMcpOriginsFrom, RUN_KEYS_ENV, switchFrom, WEB_JEV_OFF_ENV } from "./env-switch.js";
|
|
17
|
+
import { API_ONLY_ENV, API_ONLY_MCP_ORIGINS_ENV, apiOnlyMcpOriginsFrom, RUN_KEYS_ENV, SHARE_HOST_ENV, switchFrom, WEB_JEV_OFF_ENV } from "./env-switch.js";
|
|
18
18
|
import { harnessModulesOf, harnessRecipesOf } from "./harness-table.js";
|
|
19
19
|
import { hookOrigin, LAUNCH_HOOK_SECRET_ENV, LAUNCH_HOOK_URL_ENV, launchHookFrom } from "./trigger-launch-hook.js";
|
|
20
20
|
import { surviveClosedPipes } from "./closed-pipes.js";
|
|
@@ -29,7 +29,7 @@ surviveClosedPipes();
|
|
|
29
29
|
// Every outbound call through the proxy HTTPS_PROXY or HTTP_PROXY names, NO_PROXY's hosts and loopback direct
|
|
30
30
|
// (env-proxy.ts): for every command, before anything calls out. Neither set, nothing changes.
|
|
31
31
|
installEnvProxy();
|
|
32
|
-
const USAGE = `usage: agentrun-serve [--data DIR] [--listen ADDR] [--port N] [--open] [--faux MODULE] [--faux-browser MODULE] [--faux-github] [--allow-host NAME ...] [--max-runs N] [--drain-timeout D] [--documents DIR] [--allow-code-nodes] [--learning on|off] [--no-runner] [--harness-module MODULE ...] [--harness-recipe FILE ...] [--harness-sign-in]
|
|
32
|
+
const USAGE = `usage: agentrun-serve [--data DIR] [--listen ADDR] [--port N] [--open] [--faux MODULE] [--faux-browser MODULE] [--faux-github] [--allow-host NAME ...] [--max-runs N] [--drain-timeout D] [--documents DIR] [--allow-code-nodes] [--learning on|off] [--no-runner] [--share-host] [--harness-module MODULE ...] [--harness-recipe FILE ...] [--harness-sign-in]
|
|
33
33
|
agentrun-serve reset-password [--data DIR]
|
|
34
34
|
agentrun-serve validate-template DIR
|
|
35
35
|
agentrun-serve install-harness goose|cursor|antigravity [--data DIR]
|
|
@@ -90,6 +90,11 @@ const USAGE = `usage: agentrun-serve [--data DIR] [--listen ADDR] [--port N] [--
|
|
|
90
90
|
sign-in), never a schedule's or a trigger's. One owner's own machine alone: the start is refused
|
|
91
91
|
unless the server listens on loopback with no public address, keeps its store in DIR (no
|
|
92
92
|
AGENTRUN_STORE_URL), runs its runs beside it as its own user, and takes one API token
|
|
93
|
+
--share-host serve shares alone, under /r/ (as AGENTRUN_SHARE_HOST=1): a share's page at /r/<id>, its bundle at
|
|
94
|
+
/r/<id>/bundle.json, the API at /r/v2/shares (a token's upload, re-scrubbed and refused on any
|
|
95
|
+
value the scrubber finds; its list; its delete; 100 shares a token) and /r/v2/health. Every other
|
|
96
|
+
address is a 404; no runner, model key or computer runs, and there is no console or owner. Its share
|
|
97
|
+
URLs are on AGENTRUN_PUBLIC_URL, which a start on an address other than loopback needs
|
|
93
98
|
--no-runner run the server alone, with no runner beside it (default: one runner beside the server); start one or
|
|
94
99
|
more \`agentrun-serve runner --data DIR\` processes on the same data directory to claim and run runs;
|
|
95
100
|
each holds at most --loops N runs (default AGENTRUN_MAX_RUNS, else as many pi runs as its host's
|
|
@@ -520,6 +525,7 @@ else {
|
|
|
520
525
|
"allow-code-nodes": { type: "boolean", default: false },
|
|
521
526
|
learning: { type: "string" },
|
|
522
527
|
"no-runner": { type: "boolean", default: false },
|
|
528
|
+
"share-host": { type: "boolean", default: false },
|
|
523
529
|
"harness-module": { type: "string", multiple: true, default: [] },
|
|
524
530
|
"harness-recipe": { type: "string", multiple: true, default: [] },
|
|
525
531
|
"harness-sign-in": { type: "boolean", default: false },
|
|
@@ -595,10 +601,13 @@ else {
|
|
|
595
601
|
// AGENTRUN_API_ONLY_MCP_ORIGINS: the MCP origins its token may save a per_run server at (api-only.ts), read with it alone.
|
|
596
602
|
let apiOnly;
|
|
597
603
|
let runKeys;
|
|
604
|
+
// --share-host, or AGENTRUN_SHARE_HOST=1: shares under /r/ alone (share-host.ts), with no runner beside the server.
|
|
605
|
+
let shareHost;
|
|
598
606
|
let apiOnlyMcpOrigins;
|
|
599
607
|
try {
|
|
600
608
|
apiOnly = switchFrom(API_ONLY_ENV);
|
|
601
609
|
runKeys = switchFrom(RUN_KEYS_ENV);
|
|
610
|
+
shareHost = values["share-host"] === true || switchFrom(SHARE_HOST_ENV);
|
|
602
611
|
switchFrom(WEB_JEV_OFF_ENV);
|
|
603
612
|
apiOnlyMcpOrigins = apiOnly ? apiOnlyMcpOriginsFrom(process.env[API_ONLY_MCP_ORIGINS_ENV]) : [];
|
|
604
613
|
}
|
|
@@ -642,7 +651,9 @@ else {
|
|
|
642
651
|
}
|
|
643
652
|
}
|
|
644
653
|
}
|
|
645
|
-
const accounts = !apiOnly && process.env.AGENTRUN_ACCOUNTS !== "0";
|
|
654
|
+
const accounts = !apiOnly && !shareHost && process.env.AGENTRUN_ACCOUNTS !== "0";
|
|
655
|
+
// No runner beside a share host, as --no-runner.
|
|
656
|
+
const noRunner = values["no-runner"] === true || shareHost;
|
|
646
657
|
// The address first (listen-first.ts): the port bound and named before the rest of the server loads, then answering that
|
|
647
658
|
// the server is warming until it takes the socket over. A port already taken is left to the start's own listen below,
|
|
648
659
|
// which waits for a server it replaces, as it always has: no early line then. The banner's "Open " line still means ready.
|
|
@@ -684,14 +695,14 @@ else {
|
|
|
684
695
|
...(values["drain-timeout"] ? { drainTimeout: values["drain-timeout"] } : {}), ...(values.documents ? { documents: values.documents } : {}), ...(values["allow-code-nodes"] ? { allowCodeNodes: true } : {}), ...(values.learning !== undefined ? { learning: values.learning } : {}), log: (line) => void process.stdout.write(`${line}\n`),
|
|
685
696
|
// The public address is the server's with accounts on or off: the Host names it serves, the webhook URLs it gives.
|
|
686
697
|
...(publicUrl ? { publicUrl } : {}),
|
|
687
|
-
...(accounts ? { accounts, openSetup: !publicUrl, countSessions: true } : {}), ...(apiOnly ? { apiOnly } : {}), ...(launchHook ? { launchHook } : {}), ...(runKeys ? { runKeys } : {}),
|
|
698
|
+
...(accounts ? { accounts, openSetup: !publicUrl, countSessions: true } : {}), ...(apiOnly ? { apiOnly } : {}), ...(shareHost ? { shareHost } : {}), ...(launchHook ? { launchHook } : {}), ...(runKeys ? { runKeys } : {}),
|
|
688
699
|
...(apiOnlyMcpOrigins.length ? { apiOnlyMcpOrigins } : {}),
|
|
689
700
|
// The proxies whose X-Forwarded-For the sign-in limit reads (comma-separated); none unless set.
|
|
690
701
|
...(trustedProxies.length ? { trustedProxies } : {}),
|
|
691
702
|
// A local install only as its operator says, never inferred: an MCP server on loopback is refused without it.
|
|
692
703
|
...(process.env.AGENTRUN_MCP_ALLOW_LOOPBACK === "1" ? { mcpLoopback: true } : {}),
|
|
693
704
|
// No runner beside this server: a paired computer's socket stays here, where no run reaches it, which the pairing says.
|
|
694
|
-
...(
|
|
705
|
+
...(noRunner ? { runnerApart: true } : {}),
|
|
695
706
|
});
|
|
696
707
|
}
|
|
697
708
|
catch (error) {
|
|
@@ -712,7 +723,7 @@ else {
|
|
|
712
723
|
used = telemetry.used;
|
|
713
724
|
const { loops, loopsTold, drainMs } = besideRunnerOptions(serveOptions, process.env);
|
|
714
725
|
// A stop asked during the server's start starts no runner: nothing is claimed for the stop to cut.
|
|
715
|
-
if (!
|
|
726
|
+
if (!noRunner && askedAt === undefined) {
|
|
716
727
|
try {
|
|
717
728
|
// The beside-runner sees the server's test switches (server.ts fauxEnvOf: --faux and its modules), which the CLI hands
|
|
718
729
|
// the server as options, never through this process's environment: without them a --faux start's runner looks its faux
|
|
@@ -745,7 +756,7 @@ else {
|
|
|
745
756
|
}
|
|
746
757
|
// A token from the environment is the operator's already, and the stored one is printed by the start that made it only.
|
|
747
758
|
const source = given ? "env" : givenList ? "list" : serve.tokenMade ? "made" : "file";
|
|
748
|
-
for (const line of banner({ url: serve.url, baseUrl: serve.baseUrl, data, token: serve.token, source, tokenIds: serve.tokenIds, accounts, ...(apiOnly ? { apiOnly } : {}), ...(serve.launchCode ? { launchCode: serve.launchCode } : {}), boxes: serve.boxesLine, ...(values.listen ? { listen: values.listen } : {}), ...(publicUrl ? { publicUrl } : {}) }))
|
|
759
|
+
for (const line of banner({ url: serve.url, baseUrl: serve.baseUrl, data, token: serve.token, source, tokenIds: serve.tokenIds, accounts, ...(apiOnly ? { apiOnly } : {}), ...(shareHost ? { shareHost } : {}), ...(serve.launchCode ? { launchCode: serve.launchCode } : {}), ...(shareHost ? {} : { boxes: serve.boxesLine }), ...(values.listen ? { listen: values.listen } : {}), ...(publicUrl ? { publicUrl } : {}) }))
|
|
749
760
|
console.log(line);
|
|
750
761
|
if (launchHook)
|
|
751
762
|
console.log(`Launch hook (${LAUNCH_HOOK_URL_ENV}): trigger firings go to ${hookOrigin(launchHook)}, whose host starts their runs; this server starts none for them.`);
|
|
@@ -761,7 +772,7 @@ else {
|
|
|
761
772
|
// first visit sets the password with nothing to look up. That code works once and for 30 minutes, unlike the token, so
|
|
762
773
|
// the opener's arguments and the browser's history hold nothing that outlasts the setup.
|
|
763
774
|
// API-only: there is no console, so nothing to open.
|
|
764
|
-
if (values.open && !apiOnly && canOpen(process.env))
|
|
775
|
+
if (values.open && !apiOnly && !shareHost && canOpen(process.env))
|
|
765
776
|
spawn(process.platform === "darwin" ? "open" : "xdg-open", [serve.setupUrl ?? `${publicUrl ?? serve.url}/`], { stdio: "ignore", detached: true }).on("error", () => { }).unref();
|
|
766
777
|
const record = join(resolve(data), SERVER_FILE);
|
|
767
778
|
// The record goes only while it is this server's: a server that takes the lock next writes its own, which this stop must
|
|
@@ -12,6 +12,11 @@ export type ComposioCredential = {
|
|
|
12
12
|
toolkit: string;
|
|
13
13
|
auth_config?: string;
|
|
14
14
|
};
|
|
15
|
+
/** What a saved server's own routes read of it (`route`): no user, which none of them sends Composio; only a trigger's
|
|
16
|
+
* own steps (`field`) read the user. */
|
|
17
|
+
export type ComposioRouteCredential = Omit<ComposioCredential, "user">;
|
|
18
|
+
/** The credential a read for `refusal` answers. */
|
|
19
|
+
export type ComposioCredentialOf<R extends "field" | "route"> = R extends "field" ? ComposioCredential : ComposioRouteCredential;
|
|
15
20
|
/** A trigger of kind composio, as the engine keeps it. */
|
|
16
21
|
type Holder = {
|
|
17
22
|
id: string;
|
|
@@ -31,9 +36,10 @@ export type ComposioTriggerDeps = {
|
|
|
31
36
|
publicUrl?: string;
|
|
32
37
|
/** The composio source's sealed settings: each hook's subscription secret. */
|
|
33
38
|
sealed: Sealed;
|
|
34
|
-
/** Saved server `name`'s key,
|
|
35
|
-
* a trigger's create (`field`), as a 404 on its own routes
|
|
36
|
-
|
|
39
|
+
/** Saved server `name`'s key, toolkit and auth config, and for a trigger's own steps (`field`) its user; refused (thrown)
|
|
40
|
+
* when it is no Composio server: by the source's field at a trigger's create (`field`), as a 404 on its own routes
|
|
41
|
+
* (`route`). */
|
|
42
|
+
credential<R extends "field" | "route">(name: string, refusal: R): Promise<ComposioCredentialOf<R>>;
|
|
37
43
|
/** Every trigger of kind composio, on or off. */
|
|
38
44
|
holders(): Promise<Holder[]>;
|
|
39
45
|
signal?: AbortSignal;
|
package/dist/computers.d.ts
CHANGED
|
@@ -33,6 +33,9 @@ export interface ComputerRoutesOptions {
|
|
|
33
33
|
/** This server's folder mode, or how to read it at each call (folderModeOf: the Archil settings, the environment's or the saved row), so turning
|
|
34
34
|
* Archil on or off takes effect without building the routes again. */
|
|
35
35
|
readonly mode: FolderMode | (() => FolderMode | Promise<FolderMode>);
|
|
36
|
+
/** In Mode 2, this server's Archil region where it has no serverless exec (archil-settings.ts noExecRegionOf), read
|
|
37
|
+
* at each call as `mode` is: a choice with no computer that mounts the folder has no shell then. Absent: none. */
|
|
38
|
+
readonly noExec?: () => Promise<string | undefined>;
|
|
36
39
|
/** Why this machine cannot run a provider's computers, by its id (hostCommandRefusals at the server's start): the
|
|
37
40
|
* provider is not ready, and a claim of it is refused, in these words. Absent: every provider can run here. */
|
|
38
41
|
readonly hostWhy?: Readonly<Record<string, string>>;
|
package/dist/computers.js
CHANGED
|
@@ -163,7 +163,8 @@ export function createComputerRoutes(options) {
|
|
|
163
163
|
// Each provider as this server has it: the mounts its saved keys turn on, whether this server names its image, and no
|
|
164
164
|
// Archil mount where its settings make its machines dial this server.
|
|
165
165
|
const kinds = { ...listed, PROVIDERS: listed.PROVIDERS.map((provider) => entryHere(provider, (name) => saved.has(name) || envValue(env, name) !== undefined, settingOptions(provider.id, settings, keyTable))) };
|
|
166
|
-
const
|
|
166
|
+
const noExec = mode === "disk" ? await options.noExec?.() : undefined;
|
|
167
|
+
const choice = (setting) => shellChoiceOf(setting, mode === "disk" ? 2 : 1, kinds, noExec);
|
|
167
168
|
// The run's folder a computer of this choice holds, by the rule the claim picks it by, over the same providers.
|
|
168
169
|
const folderOf = (setting) => runFolderOf(setting, mode === "disk" ? 2 : 1, kinds) ?? null;
|
|
169
170
|
// Under this server's AGENTRUN_BOX_ALLOW none, a computer that needs a network is refused at a
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{d as It,D as Yn}from"./index-
|
|
1
|
+
import{d as It,D as Yn}from"./index-CG5tELph.js";import{az as bt}from"./styles-BGZxYkky.js";const we=t=>({type:"boolean",description:t}),Yt={type:"object",required:["name","pageCount","pages","text"],properties:{name:{type:"string"},pageCount:{type:"integer"},pages:{type:"array"},text:{type:"string"}}},Jn={type:"object",required:["status","text"],properties:{status:{type:"integer"},url:{type:"string"},title:{type:"string"},text:{type:"string"}}},vt={type:"object"},Ke={type:"object",additionalProperties:!1,required:["altered","seal","signature","legible"],properties:{altered:we("Does the page show signs of digital alteration: mismatched fonts, misaligned lines, pasted regions or an edited date?"),seal:we("Is a state seal or a filing stamp visible on the page?"),signature:we("Is the certificate signed by a state official?"),legible:we("Is the entity's full legal name legible on the page?")}},mt={v:2,name:"coi-batch-review",schemas:{Input:{type:"object",required:["documents"],properties:{documents:{type:"array",items:{type:"string"},minItems:1,maxItems:50}}},DocChecks:Ke,Pages:Yt,Report:vt},input:{schemaId:"Input"},output:{schemaId:"Report",path:"report"},root:{node:"chain",steps:[{node:"map",label:"each-document",itemsPath:"documents",as:"rows",maxConcurrency:4,onItemFailure:"collect",failedAs:"failed",body:{node:"chain",steps:[{node:"call",label:"render-pages",via:"tool",tool:"pdf_pages",args:{path:"{item}",maxPages:2},out:"Pages",as:"pages",deadline_s:60},{node:"judge",label:"inspect-certificate",provider:"jev",state:{document:"{item}",page:"<page1>",text:"{pages.text}"},images:{"<page1>":"{pages.pages.0.image}"},out:"DocChecks",as:"checks"},{node:"code",label:"grade",code:"(s) => ({ document: s.item, verdict: s.checks.altered || !s.checks.seal || !s.checks.legible ? 'doubtful' : 'valid', checks: s.checks })",as:"row"}]}},{node:"code",label:"batch-report",code:"(s) => ({ valid: s.rows.filter((r) => r && r.verdict === 'valid').length, doubtful: s.rows.filter((r) => r && r.verdict === 'doubtful').map((r) => r.document), failed: s.failed })",as:"report"}]}},xe={v:2,name:"kyb-onboarding",schemas:{Pages:Yt,Result:vt,Input:{type:"object",required:["company","state","registration_number","documents"],properties:{company:{type:"string"},state:{type:"string"},registration_number:{type:"string"},documents:{type:"array",items:{type:"string"}}}},Registry:{type:"object",additionalProperties:!1,required:["registered","active","name_matches"],properties:{registered:we("Is a company with this exact registration number on file with the named state's business registry?"),active:we("Is that registration currently active (in good standing, not dissolved, forfeited or revoked)?"),name_matches:we("Does the registry's legal name match the applicant's name, ignoring punctuation and suffix style?")}},CertLook:{type:"object",additionalProperties:!1,required:["altered","seal","legible"],properties:{altered:Ke.properties.altered,seal:Ke.properties.seal,legible:Ke.properties.legible}},CrossCheck:{type:"object",additionalProperties:!1,required:["same_entity","same_state","dates_consistent"],properties:{same_entity:we("Do the registry record and the certificate name the same legal entity?"),same_state:we("Do they name the same state of incorporation?"),dates_consistent:we("Is the certificate's filing date consistent with the registry's formation date (within 3 days)?")}}},input:{schemaId:"Input"},root:{node:"chain",steps:[{node:"call",label:"render-certificate",via:"tool",tool:"pdf_pages",args:{path:"{documents.0}",maxPages:1},out:"Pages",as:"cert",deadline_s:60},{node:"parallel",label:"checks",branches:[{node:"judge",label:"registry-lookup",provider:"parallel",model:"standard",state:{company:"{company}",state:"{state}",registration_number:"{registration_number}"},out:"Registry",as:"registry"},{node:"judge",label:"certificate-look",provider:"jev",state:{page:"<cert>",text:"{cert.text}"},images:{"<cert>":"{cert.pages.0.image}"},out:"CertLook",as:"look"}]},{node:"judge",label:"cross-check",provider:"jev",state:{applicant:{company:"{company}",state:"{state}"},registry:"{registry$answers}",certificate_text:"{cert.text}"},out:"CrossCheck",as:"cross"},{node:"route",label:"decide",provider:"jev",state:{registry:"{registry}",look:"{look}",cross:"{cross}"},instructions:"Decide the onboarding outcome for this business from the registry check, the certificate's look and the cross-check.",branches:{approve:{criteria:"Registered, active, the certificate looks genuine, and every cross-check agrees.",body:{node:"code",label:"record-approval",code:"(s) => ({ outcome: 'approved' })",as:"outcome"}},review:{criteria:"Mostly consistent, but one check is doubtful or the evidence disagrees on a detail.",body:{node:"code",label:"open-review-case",code:"(s) => ({ outcome: 'review', reasons: s.cross })",as:"outcome"}},reject:{criteria:"Not registered, dissolved, or the certificate is altered.",body:{node:"code",label:"record-rejection",code:"(s) => ({ outcome: 'rejected' })",as:"outcome"}}},unsure:{branch:"review",gte:.75}}]},output:{schemaId:"Result",path:"outcome"}},Vn={type:"object",additionalProperties:!1,required:["prohibited"],properties:{prohibited:we("Does this merchant sell goods the card networks prohibit: weapons, controlled substances, counterfeit goods, or unlicensed nicotine products?")}},Ve=(t,s,o)=>({node:"judge",label:t,provider:s,...o?{model:o}:{},state:{merchant:"{merchant}",url:"{url}",page_text:"{page.text}"},out:"Prohibited",as:t.replace(/-/g,"_")}),Ze={v:2,name:"prohibited-goods-jury",schemas:{Page:Jn,Result:vt,Input:{type:"object",required:["merchant","url"],properties:{merchant:{type:"string"},url:{type:"string"}}},Prohibited:Vn},input:{schemaId:"Input"},root:{node:"chain",steps:[{node:"call",label:"fetch-storefront",via:"tool",tool:"web_fetch",args:{url:"{url}"},out:"Page",as:"page",deadline_s:30},{node:"parallel",label:"jury",branches:[Ve("jev","jev"),Ve("pplx-decider","openrouter","perplexity/pplx-decider-v1.2"),Ve("liquid-d1","openrouter","liquid/d1"),Ve("clef","openrouter","cloudflare/clef")]},{node:"code",label:"aggregate",code:"(s) => { const p = [s.jev$answers, s.pplx_decider$answers, s.liquid_d1$answers, s.clef$answers].map((a) => a.answers.prohibited.noul); const mean = p.reduce((x, y) => x + y, 0) / p.length; const spread = Math.max(...p) - Math.min(...p); return { mean, spread, outcome: spread > 0.3 ? 'disagree' : 'agree' }; }",as:"agreement"},{node:"route",label:"agreement",valuePath:"agreement.outcome",branches:{agree:{body:{node:"code",label:"auto-decide",code:"(s) => ({ decision: s.agreement.mean >= 0.5 ? 'decline' : 'approve' })",as:"decision"}},disagree:{body:{node:"code",label:"human-review",code:"(s) => ({ decision: 'review', spread: s.agreement.spread })",as:"decision"}}}}]},output:{schemaId:"Result",path:"decision"}},re=6e4,le=60*re,W=24*le,se={default:"anthropic/claude-sonnet-5-5",fast:"openai/gpt-6-luna",strong:"anthropic/claude-opus-5-5",codex:"openai/gpt-6.1-sol"},Qn={v:2,name:"ticket-triage",schemas:{Ticket:{type:"object",required:["subject","body"],properties:{subject:{type:"string"},body:{type:"string"}}},Triage:{type:"object",required:["queue","urgency"],properties:{queue:{type:"string"},urgency:{type:"integer"}}}},input:{schemaId:"Ticket"},output:{schemaId:"Triage",path:"triage"},root:{node:"chain",steps:[{node:"call",label:"read the playbook",tool:"read",args:{path:"playbooks/triage.md"},as:"playbook"},{node:"pick",label:"which queue",from:"playbook.queues",instructions:"Which queue does this ticket belong to, by what the buyer or seller asks for?",as:"queue",none:"hand back"},{node:"code",label:"score the urgency",as:"triage"}]}},Zn=`# ticket-triage
|
|
2
2
|
|
|
3
3
|
Files a ticket under its queue (billing, shipping, account, merchant, abuse) and scores its urgency from the playbook: a chargeback, a locked account or a safety problem is 4 or more.
|
|
4
4
|
|