@parcha/agentrun-serve 0.1.0-beta.59 → 0.1.0-beta.61
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 +135 -0
- package/README.md +230 -120
- package/dist/acp-package.d.ts +4 -0
- package/dist/agent-delete.d.ts +6 -9
- package/dist/agent-delete.js +5 -3
- package/dist/agent-package.js +11 -1
- package/dist/api-only.d.ts +21 -3
- package/dist/api-only.js +41 -6
- package/dist/archil-routes.d.ts +4 -1
- package/dist/archil-routes.js +15 -12
- package/dist/archil-settings.d.ts +18 -8
- package/dist/archil-settings.js +35 -17
- package/dist/browser-person.d.ts +1 -1
- package/dist/browser-person.js +1 -1
- package/dist/calendar/tools.js +1 -1
- package/dist/chatgpt-plan.d.ts +4 -2
- package/dist/chatgpt-plan.js +13 -3
- package/dist/claude-login-token.d.ts +5 -0
- package/dist/claude-login-token.js +8 -0
- package/dist/claude-login.d.ts +49 -3
- package/dist/claude-login.js +140 -10
- package/dist/cli-learning/connections.js +1 -1
- package/dist/cli.js +42 -10
- package/dist/console/assets/{backend-BztxEAvb.js → backend-C9ffXUR5.js} +1 -1
- package/dist/console/assets/index-BnZV3lvW.js +639 -0
- package/dist/console/assets/{share-L84tlUDW.js → share-B1o5mJ56.js} +2 -2
- package/dist/console/assets/{styles-CaRKlHke.js → styles-D_znYrHR.js} +31 -31
- package/dist/console/assets/styles-fjQBFfMv.css +1 -0
- package/dist/console/index.html +3 -3
- package/dist/console/share.html +3 -3
- package/dist/decisions.d.ts +1 -1
- package/dist/decisions.js +2 -2
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +2 -0
- package/dist/factory-activity.d.ts +68 -0
- package/dist/factory-activity.js +153 -0
- package/dist/factory-runs.d.ts +11 -0
- package/dist/factory-runs.js +52 -0
- package/dist/filed-tool.d.ts +32 -0
- package/dist/filed-tool.js +122 -0
- package/dist/harness-check.js +2 -1
- package/dist/harness-keys.d.ts +1 -2
- package/dist/harness-keys.js +1 -2
- package/dist/harness-recipe.d.ts +13 -2
- package/dist/harness-recipe.js +30 -7
- package/dist/harness-sign-in.js +2 -1
- package/dist/harness-table.d.ts +9 -3
- package/dist/harness-table.js +11 -5
- package/dist/harness.js +6 -2
- package/dist/import-worker.js +2 -2
- package/dist/import.d.ts +9 -0
- package/dist/import.js +11 -1
- package/dist/key-refusal.d.ts +5 -0
- package/dist/key-refusal.js +30 -18
- package/dist/learn/audit.d.ts +20 -22
- package/dist/learn/audit.js +72 -55
- package/dist/learn/check.js +1 -1
- package/dist/learn/commit.d.ts +35 -43
- package/dist/learn/commit.js +62 -270
- package/dist/learn/compile.d.ts +4 -4
- package/dist/learn/compile.js +6 -7
- package/dist/learn/corrections.js +1 -1
- package/dist/learn/delete.d.ts +5 -12
- package/dist/learn/delete.js +17 -30
- package/dist/learn/forget-run.d.ts +16 -0
- package/dist/learn/forget-run.js +53 -0
- package/dist/learn/index.js +1 -1
- package/dist/learn/learning-of.d.ts +0 -4
- package/dist/learn/learning-of.js +0 -5
- package/dist/learn/{folder.d.ts → legacy/folder.d.ts} +2 -1
- package/dist/learn/{folder.js → legacy/folder.js} +4 -7
- package/dist/learn/legacy/place.d.ts +16 -0
- package/dist/{workspace/learning-workspace.js → learn/legacy/place.js} +12 -42
- package/dist/learn/legacy/scrub.d.ts +28 -0
- package/dist/learn/legacy/scrub.js +258 -0
- package/dist/learn/promote.d.ts +40 -66
- package/dist/learn/promote.js +69 -207
- package/dist/learn/reset-ledger.d.ts +18 -0
- package/dist/learn/reset-ledger.js +14 -0
- package/dist/learn/rows.d.ts +186 -0
- package/dist/learn/rows.js +376 -0
- package/dist/learn/secrets.d.ts +2 -1
- package/dist/learn/secrets.js +2 -2
- package/dist/learn/workflow-draft.d.ts +4 -1
- package/dist/learn/workflow-draft.js +12 -2
- package/dist/learned-nodes.d.ts +36 -0
- package/dist/learned-nodes.js +23 -0
- package/dist/learning-reset.d.ts +1 -1
- package/dist/learning-reset.js +9 -11
- package/dist/learning-routes.d.ts +60 -81
- package/dist/learning-routes.js +187 -360
- package/dist/learning-words.d.ts +2 -0
- package/dist/learning-words.js +2 -0
- package/dist/learning.d.ts +18 -24
- package/dist/learning.js +35 -66
- package/dist/local-model.d.ts +144 -0
- package/dist/local-model.js +214 -0
- package/dist/mcp-gateway.d.ts +6 -0
- package/dist/mcp-gateway.js +44 -8
- package/dist/mcp-probe.d.ts +7 -0
- package/dist/mcp-probe.js +7 -0
- package/dist/mcp-resources.d.ts +1 -1
- package/dist/native/discovery.d.ts +6 -0
- package/dist/native/discovery.js +14 -1
- package/dist/native/remote.d.ts +5 -0
- package/dist/native/remote.js +16 -0
- package/dist/native/runtime.js +3 -2
- package/dist/observation/observer.d.ts +6 -6
- package/dist/ollama-provider.d.ts +35 -0
- package/dist/ollama-provider.js +108 -2
- package/dist/openapi.js +147 -35
- package/dist/place-offers.d.ts +3 -0
- package/dist/place-offers.js +3 -0
- package/dist/place.d.ts +35 -12
- package/dist/place.js +67 -29
- package/dist/print.js +1 -1
- package/dist/purged-workflow.d.ts +0 -33
- package/dist/purged-workflow.js +3 -71
- package/dist/redact/match.d.ts +36 -8
- package/dist/redact/match.js +179 -44
- package/dist/run-export.js +4 -2
- package/dist/run-launch.d.ts +3 -3
- package/dist/run-learning-served.d.ts +3 -3
- package/dist/run-learning-served.js +1 -1
- package/dist/run-listing.d.ts +1 -1
- package/dist/run-timeline-served.d.ts +1 -1
- package/dist/run-timeline-served.js +6 -5
- package/dist/run-usage.js +3 -2
- package/dist/runnable.js +25 -8
- package/dist/runner/adapter-loop.d.ts +8 -1
- package/dist/runner/adapter-loop.js +100 -20
- package/dist/runner/adapter-run-spec.d.ts +3 -5
- package/dist/runner/adapter-run-spec.js +35 -61
- package/dist/runner/adapters/pi.d.ts +3 -2
- package/dist/runner/adapters/pi.js +3 -1
- package/dist/runner/audit.d.ts +3 -5
- package/dist/runner/audit.js +28 -51
- package/dist/runner/cli-run-spec.js +19 -22
- package/dist/runner/compare-end.d.ts +1 -3
- package/dist/runner/compare-end.js +6 -2
- package/dist/runner/disk-free.d.ts +15 -4
- package/dist/runner/disk-free.js +25 -7
- package/dist/runner/dispatch.js +2 -2
- package/dist/runner/feedback-round.d.ts +1 -1
- package/dist/runner/feedback-round.js +2 -2
- package/dist/runner/harness-loops.d.ts +9 -0
- package/dist/runner/harness-loops.js +49 -7
- package/dist/runner/held.d.ts +4 -11
- package/dist/runner/held.js +0 -25
- package/dist/runner/journal-kinds.d.ts +4 -1
- package/dist/runner/journal-kinds.js +1 -1
- package/dist/runner/learned-first.d.ts +0 -2
- package/dist/runner/learned-first.js +3 -3
- package/dist/runner/learning-end.d.ts +12 -16
- package/dist/runner/learning-end.js +41 -75
- package/dist/runner/learning-seed.d.ts +13 -16
- package/dist/runner/learning-seed.js +13 -23
- package/dist/runner/live-ticker.js +3 -4
- package/dist/runner/main.js +1 -1
- package/dist/runner/mcp-claim.js +3 -2
- package/dist/runner/mcp-run.d.ts +23 -4
- package/dist/runner/mcp-run.js +31 -2
- package/dist/runner/metrics.d.ts +4 -0
- package/dist/runner/metrics.js +9 -3
- package/dist/runner/monid-run.js +3 -1
- package/dist/runner/native-loop.js +3 -4
- package/dist/runner/promotion.d.ts +19 -28
- package/dist/runner/promotion.js +50 -69
- package/dist/runner/redact.d.ts +3 -0
- package/dist/runner/redact.js +7 -0
- package/dist/runner/reflect-hook.d.ts +2 -2
- package/dist/runner/reflect-hook.js +4 -1
- package/dist/runner/run-child-host.d.ts +1 -9
- package/dist/runner/run-child-host.js +12 -68
- package/dist/runner/runner.d.ts +1 -1
- package/dist/runner/sdk-loop.js +7 -7
- package/dist/runner/workflow-calls.d.ts +4 -1
- package/dist/runner/workflow-calls.js +35 -18
- package/dist/runner/workflow-loop.d.ts +1 -1
- package/dist/runner/workflow-loop.js +3 -1
- package/dist/runner/workflow-spec.d.ts +4 -0
- package/dist/runner/workflow-spec.js +18 -13
- package/dist/runs-over-store.d.ts +2 -2
- package/dist/runs-over-store.js +1 -1
- package/dist/sdk/check.d.ts +1 -4
- package/dist/sdk/check.js +2 -3
- package/dist/sdk/runs.d.ts +20 -7
- package/dist/sdk/runs.js +105 -68
- package/dist/secret-cut.js +7 -4
- package/dist/secret-rules.js +97 -83
- package/dist/secrets.d.ts +4 -0
- package/dist/secrets.js +44 -10
- package/dist/server-fs.d.ts +1 -1
- package/dist/server-fs.js +1 -1
- package/dist/server-keys.d.ts +6 -0
- package/dist/server-keys.js +12 -0
- package/dist/server.d.ts +22 -15
- package/dist/server.js +311 -198
- package/dist/slack.js +2 -1
- package/dist/source-sync/auxiliary.js +2 -2
- package/dist/store/index.d.ts +1 -1
- package/dist/store/index.js +1 -1
- package/dist/store/postgres/migrate.js +3 -1
- package/dist/store/postgres/migrations/0032_learning_rows.sql +65 -0
- package/dist/store/schema.d.ts +28 -2
- package/dist/store/schema.js +81 -5
- package/dist/store/sqlite/learning-rows.d.ts +23 -0
- package/dist/store/sqlite/learning-rows.js +559 -0
- package/dist/store/sqlite/store.d.ts +7 -1
- package/dist/store/sqlite/store.js +84 -18
- package/dist/store/store.d.ts +219 -6
- package/dist/store/store.js +13 -0
- package/dist/store-reads/journal.d.ts +33 -3
- package/dist/store-reads/journal.js +99 -4
- package/dist/store-reads/learning.d.ts +23 -26
- package/dist/store-reads/learning.js +42 -30
- package/dist/store-reads/loop.js +1 -1
- package/dist/store-view.d.ts +24 -2
- package/dist/store-view.js +40 -11
- package/dist/templates.d.ts +10 -2
- package/dist/templates.js +31 -4
- package/dist/tool-plane.d.ts +27 -3
- package/dist/tool-plane.js +79 -4
- package/dist/tools.d.ts +12 -2
- package/dist/tools.js +42 -7
- package/dist/trigger-launch-hook.d.ts +2 -2
- package/dist/trigger-launch-hook.js +1 -1
- package/dist/triggers.d.ts +7 -4
- package/dist/triggers.js +4 -4
- package/dist/web-holds.d.ts +2 -0
- package/dist/web-holds.js +5 -2
- package/dist/web-run.js +2 -1
- package/dist/workspace/archil-exec.js +1 -1
- package/dist/workspace/archil.d.ts +1 -1
- package/dist/workspace/archil.js +1 -1
- package/dist/workspace/computer-deps.js +5 -3
- package/dist/workspace/computer-providers.d.ts +11 -1
- package/dist/workspace/computer-providers.js +29 -2
- package/dist/workspace/index.d.ts +1 -2
- package/dist/workspace/index.js +1 -2
- package/dist/workspace/paths.d.ts +0 -4
- package/dist/workspace/paths.js +0 -6
- package/dist/workspace/workspace.d.ts +1 -1
- package/dist/workspace/workspace.js +1 -1
- package/package.json +13 -13
- package/templates/TOOLS.md +46 -0
- package/dist/console/assets/index-LwNL4L9q.js +0 -619
- package/dist/console/assets/styles-DQo8rzY-.css +0 -1
- package/dist/workspace/learning-workspace.d.ts +0 -24
- /package/dist/learn/{learning.sh → legacy/learning.sh} +0 -0
package/dist/place-offers.d.ts
CHANGED
|
@@ -21,6 +21,9 @@ export declare const BOX_IDS: readonly string[];
|
|
|
21
21
|
* version` (probeDocker), its computers mount this server's paths (box-paths.ts) and keep out the Docker host's own
|
|
22
22
|
* addresses (docker-host-addresses.ts). */
|
|
23
23
|
export declare const LOCAL_BOXES: readonly string[];
|
|
24
|
+
/** The box a new agent that names no place and needs a shell is given (its descriptor's `defaultBox`: Docker's), by
|
|
25
|
+
* that fact, never by a name; undefined where no box's descriptor sets it. */
|
|
26
|
+
export declare const DEFAULT_BOX: string | undefined;
|
|
24
27
|
/** A box as capabilities show it: whether this server has it, and why when not (or how it was checked); `state`, which
|
|
25
28
|
* capabilities derive from it (place.ts stated). `network`: what an available box reaches (BOX_NETWORKS), with
|
|
26
29
|
* `network_reason` when it is available and has none for a cause of its own (a daemon elsewhere). `host_addresses`: for Docker from a container (compose.yaml), the Docker host's own addresses
|
package/dist/place-offers.js
CHANGED
|
@@ -45,6 +45,9 @@ const boxEntry = (id) => PROVIDERS.find((entry) => entry.id === id);
|
|
|
45
45
|
* version` (probeDocker), its computers mount this server's paths (box-paths.ts) and keep out the Docker host's own
|
|
46
46
|
* addresses (docker-host-addresses.ts). */
|
|
47
47
|
export const LOCAL_BOXES = BOX_IDS.filter((id) => boxEntry(id).local === true);
|
|
48
|
+
/** The box a new agent that names no place and needs a shell is given (its descriptor's `defaultBox`: Docker's), by
|
|
49
|
+
* that fact, never by a name; undefined where no box's descriptor sets it. */
|
|
50
|
+
export const DEFAULT_BOX = BOX_IDS.find((id) => boxEntry(id).defaultBox === true);
|
|
48
51
|
/** What an available box reaches: the hosts of `places.allow` (`allowlist`), or nothing (`none`). */
|
|
49
52
|
export const BOX_NETWORKS = ["allowlist", "none"];
|
|
50
53
|
/** A box's state in capabilities: ready (available) or unavailable. */
|
package/dist/place.d.ts
CHANGED
|
@@ -10,9 +10,15 @@ export type Place = {
|
|
|
10
10
|
};
|
|
11
11
|
/** Every box, from what this server found at its start (place-offers.ts): one it did not find is not set up. */
|
|
12
12
|
export declare function boxAvailability(registry: readonly BoxOffer[]): BoxOffer[];
|
|
13
|
-
/**
|
|
14
|
-
*
|
|
15
|
-
|
|
13
|
+
/** What a new agent that would get Docker's box sets where this server does not have it: a box, listing the boxes this
|
|
14
|
+
* server has (never picking one), or the runner. */
|
|
15
|
+
export declare function placeToName(registry: readonly BoxOffer[]): string;
|
|
16
|
+
/** Why such an agent is refused: it names a box (placeToName); and why Docker's box is not here, in the words its offer
|
|
17
|
+
* gave (its probe's, with their fix: start Docker, join its group), where it gave some. */
|
|
18
|
+
export declare const nameABox: (registry: readonly BoxOffer[]) => string;
|
|
19
|
+
/** The place a new agentic definition that names none is saved with: Docker's box where this server has it; else none,
|
|
20
|
+
* with `reason`, the words such a definition is refused in (nameABox), and `why` Docker's box is not here, in its probe's
|
|
21
|
+
* own words. A workflow is never given one. */
|
|
16
22
|
export declare function newAgentPlace(registry: readonly BoxOffer[]): {
|
|
17
23
|
place: Place;
|
|
18
24
|
} | {
|
|
@@ -23,11 +29,22 @@ export declare function newAgentPlace(registry: readonly BoxOffer[]): {
|
|
|
23
29
|
* (newAgentPlace) for an agentic revision with a tool that runs only in a box (`flags`, tools.ts: bash and the
|
|
24
30
|
* background tools); the runner for a workflow, which is never given a box, for one whose tools need no shell (none, or
|
|
25
31
|
* only read and write: a container would only hold up its start), and for one that names a tool the box refuses (the
|
|
26
|
-
* browser, runner-only for now).
|
|
27
|
-
|
|
32
|
+
* browser, runner-only for now). Where the runner has a shell (`runnerShell`: Mode 2's Archil exec), the runner for
|
|
33
|
+
* every revision: Docker's box can't mount the folder Mode 2 keeps on Archil. */
|
|
34
|
+
export declare function defaultPlaceOf(kind: "agentic" | "workflow", tools: readonly unknown[], registry: readonly BoxOffer[], flags: ToolFlags, runnerShell: boolean): Place;
|
|
35
|
+
type ToolFlags = (tool: string) => {
|
|
28
36
|
readonly sandboxOnly?: true;
|
|
29
37
|
readonly runnerOnly?: true;
|
|
30
|
-
} | undefined
|
|
38
|
+
} | undefined;
|
|
39
|
+
/** The refusal of an agentic definition that names no place (noPlaceIssue), at its create or at an edit that would
|
|
40
|
+
* save it, where it would be given the default box (it names no tools, `tools` undefined, so it would get a shell, or a
|
|
41
|
+
* tool that runs only in a box) and this server does not have Docker's box, and where the runner has no shell
|
|
42
|
+
* (`runnerShell` false: Mode 1). On Mode 2 the runner's exec is a shell, and such a definition saves for the runner as
|
|
43
|
+
* it always did, its tools checked there (runnable.ts). Undefined for one that saves. */
|
|
44
|
+
export declare function noBoxRefusal(tools: readonly unknown[] | undefined, registry: readonly BoxOffer[], flags: ToolFlags, runnerShell: boolean): InputIssue | undefined;
|
|
45
|
+
/** The refusal of a revision that names no place where Docker's box is not here, at definition.place: its words, and
|
|
46
|
+
* what to set as its fix, so no example of a place is picked for it. */
|
|
47
|
+
export declare const noPlaceIssue: (registry: readonly BoxOffer[]) => InputIssue;
|
|
31
48
|
/** The tools a new agent in the default box is given when its definition names none: a shell, and the background tools
|
|
32
49
|
* that start, read, feed, signal and list commands that outlive one call (background.ts SHELL_TOOLS, which a test holds
|
|
33
50
|
* this list to; written out here, since background.ts reads this module). A definition that names its tools, an empty
|
|
@@ -39,20 +56,25 @@ export declare function noBoxReason(registry: readonly BoxOffer[], listed: Reado
|
|
|
39
56
|
/** The start banner's words on the boxes: which are ready for a sandbox agent's tools, then why each box is not that
|
|
40
57
|
* AGENTRUN_BOXES lists (`listed`), and, when none is ready, the boxes it does not list, with what to do.
|
|
41
58
|
* `byDefault`, with AGENTRUN_BOXES not set at all: short, the local box alone, said to be on by default, or why it is
|
|
42
|
-
* not
|
|
43
|
-
|
|
59
|
+
* not, and where a new agent with no place goes then: it names its place, or, where the runner has a shell
|
|
60
|
+
* (`runnerShell`: Mode 2), it runs on the runner (placesOf). */
|
|
61
|
+
export declare function boxesLine(registry: readonly BoxOffer[], listed: ReadonlySet<string>, allow?: readonly string[] | "none", byDefault?: boolean, runnerShell?: boolean): string;
|
|
44
62
|
/** `places` in capabilities: the modes a revision may name, the place a new agent is saved with and a revision that
|
|
45
|
-
* names none runs in (`default_place
|
|
46
|
-
*
|
|
47
|
-
|
|
63
|
+
* names none runs in (`default_place`), each box, and the hosts a box whose `network` is `allowlist` reaches (`allow`,
|
|
64
|
+
* box-settings.ts boxAllowOf; empty for `none`). `default_place` is the runner where it has a shell (`runnerShell`:
|
|
65
|
+
* Mode 2's Archil exec), Docker answering or not (defaultPlaceOf); else Docker's box where this server has it; else
|
|
66
|
+
* null, no default: a new agent names its place, and `default_reason` is the words a no-place create is refused in
|
|
67
|
+
* (noBoxRefusal). `default_reason` is there exactly when `default_place` is null. */
|
|
68
|
+
export declare const placesOf: (registry: readonly BoxOffer[], allow?: readonly string[] | "none", runnerShell?: boolean) => {
|
|
48
69
|
boxes: BoxOffer[];
|
|
49
70
|
allow: string[];
|
|
50
71
|
default_place: Place;
|
|
72
|
+
default_reason?: undefined;
|
|
51
73
|
modes: ("runner" | "sandbox")[];
|
|
52
74
|
} | {
|
|
53
75
|
boxes: BoxOffer[];
|
|
54
76
|
allow: string[];
|
|
55
|
-
default_place:
|
|
77
|
+
default_place: null;
|
|
56
78
|
default_reason: string;
|
|
57
79
|
modes: ("runner" | "sandbox")[];
|
|
58
80
|
};
|
|
@@ -65,3 +87,4 @@ export declare const placeFix: (place: Place) => string;
|
|
|
65
87
|
/** What is wrong with `place` as a definition gives it, as issues at `field`. Each names its fix: the field to remove,
|
|
66
88
|
* or the place to copy, the one it most likely meant. */
|
|
67
89
|
export declare function placeIssues(place: unknown, field: string): InputIssue[];
|
|
90
|
+
export {};
|
package/dist/place.js
CHANGED
|
@@ -9,13 +9,16 @@
|
|
|
9
9
|
// sandbox, never a third mode.
|
|
10
10
|
//
|
|
11
11
|
// The box is a new agent's default machine for a shell: an agentic definition that names no place and no tools is saved,
|
|
12
|
-
// at its create, with
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
|
|
12
|
+
// at its create, with Docker's box as its place wherever this server has it, and with bash (newAgentPlace). One that
|
|
13
|
+
// names its tools gets the box only when one of them needs a shell; else it keeps no place and runs on the runner, with
|
|
14
|
+
// no container to wait for. Where Docker's box is not here, a definition that would get it is refused (noBoxRefusal):
|
|
15
|
+
// it names a box or the runner, and no other box that answers is picked for it. A revision that names no place resolves
|
|
16
|
+
// the same way at each run (defaultPlaceOf): with a shell tool, this server's default_place, so where docker is there
|
|
17
|
+
// now it runs in the Docker box, and where it is not its run is refused in the same words. A workflow, a revision whose
|
|
18
|
+
// tools need no shell, and one with a tool the box refuses run on the runner. In Mode 2 (the runner's shell is Archil's
|
|
19
|
+
// serverless exec) the default is the runner, Docker answering or not: Mode 2 keeps the run's folder on Archil, which
|
|
20
|
+
// Docker's box can't mount, so a run given that box would only be refused.
|
|
21
|
+
import { BOX_IDS, BOXES_ENV, DEFAULT_BOX } from "./place-offers.js";
|
|
19
22
|
import { sentence } from "./errors.js";
|
|
20
23
|
export const PLACE_MODES = ["runner", "sandbox"];
|
|
21
24
|
/** Every box, from what this server found at its start (place-offers.ts): one it did not find is not set up. */
|
|
@@ -25,34 +28,64 @@ export function boxAvailability(registry) {
|
|
|
25
28
|
return offer ? { ...offer } : { id, available: false, reason: `${id} is not set up on this server` };
|
|
26
29
|
});
|
|
27
30
|
}
|
|
28
|
-
/** The box a new agent is given: the
|
|
29
|
-
*
|
|
30
|
-
const defaultBox = (registry) =>
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
/** The box a new agent is given: the one whose provider's descriptor says so (`defaultBox`: Docker's), never another box
|
|
32
|
+
* that answers in its place. */
|
|
33
|
+
const defaultBox = (registry) => boxAvailability(registry).find((box) => box.id === DEFAULT_BOX);
|
|
34
|
+
/** Why Docker's box is not here when its probe gave no reason (the words this server always used). */
|
|
35
|
+
const NO_REASON = "no provider runs computers on this machine";
|
|
36
|
+
/** What a new agent that would get Docker's box sets where this server does not have it: a box, listing the boxes this
|
|
37
|
+
* server has (never picking one), or the runner. */
|
|
38
|
+
export function placeToName(registry) {
|
|
39
|
+
const ready = boxAvailability(registry).filter((box) => box.available).map((box) => box.id);
|
|
40
|
+
return `Set place to {mode: sandbox, box: <${ready.length ? `one of: ${ready.join(", ")}` : "none is set up"}>}, or to {mode: runner} to run without a shell.`;
|
|
41
|
+
}
|
|
42
|
+
/** Why such an agent is refused: it names a box (placeToName); and why Docker's box is not here, in the words its offer
|
|
43
|
+
* gave (its probe's, with their fix: start Docker, join its group), where it gave some. */
|
|
44
|
+
export const nameABox = (registry) => {
|
|
45
|
+
const why = registry.find((offer) => offer.id === DEFAULT_BOX && !offer.available)?.reason;
|
|
46
|
+
return `name a box: this server has no Docker box for a new agent. ${placeToName(registry)}${why ? ` ${sentence(`${DEFAULT_BOX}: ${why}`)}` : ""}`;
|
|
33
47
|
};
|
|
34
|
-
/** The place a new agentic definition that names none is saved with:
|
|
35
|
-
*
|
|
36
|
-
* workflow is never given one. */
|
|
48
|
+
/** The place a new agentic definition that names none is saved with: Docker's box where this server has it; else none,
|
|
49
|
+
* with `reason`, the words such a definition is refused in (nameABox), and `why` Docker's box is not here, in its probe's
|
|
50
|
+
* own words. A workflow is never given one. */
|
|
37
51
|
export function newAgentPlace(registry) {
|
|
38
52
|
const box = defaultBox(registry);
|
|
39
53
|
if (box?.available)
|
|
40
54
|
return { place: { mode: "sandbox", box: box.id } };
|
|
41
|
-
|
|
42
|
-
return { reason: `new agents run on the runner, because the ${box?.id ?? "local"} box is unavailable here: ${why}`, why };
|
|
55
|
+
return { reason: nameABox(registry), why: box?.reason ?? NO_REASON };
|
|
43
56
|
}
|
|
44
57
|
/** The place a revision that names none resolves to, at its create and at each run alike: this server's default place
|
|
45
58
|
* (newAgentPlace) for an agentic revision with a tool that runs only in a box (`flags`, tools.ts: bash and the
|
|
46
59
|
* background tools); the runner for a workflow, which is never given a box, for one whose tools need no shell (none, or
|
|
47
60
|
* only read and write: a container would only hold up its start), and for one that names a tool the box refuses (the
|
|
48
|
-
* browser, runner-only for now).
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (kind === "workflow" ||
|
|
61
|
+
* browser, runner-only for now). Where the runner has a shell (`runnerShell`: Mode 2's Archil exec), the runner for
|
|
62
|
+
* every revision: Docker's box can't mount the folder Mode 2 keeps on Archil. */
|
|
63
|
+
export function defaultPlaceOf(kind, tools, registry, flags, runnerShell) {
|
|
64
|
+
if (kind === "workflow" || runnerShell || !wantsBox(tools, flags))
|
|
52
65
|
return { mode: "runner" };
|
|
53
66
|
const fresh = newAgentPlace(registry);
|
|
54
67
|
return "place" in fresh ? fresh.place : { mode: "runner" };
|
|
55
68
|
}
|
|
69
|
+
/** Whether an agentic revision naming `tools` and no place would be given the default box: one of them runs only in a
|
|
70
|
+
* box, and none is a tool the box refuses. */
|
|
71
|
+
const wantsBox = (tools, flags) => {
|
|
72
|
+
const named = tools.flatMap((tool) => (typeof tool === "string" ? [flags(tool)] : []));
|
|
73
|
+
return !named.some((tool) => tool?.runnerOnly) && named.some((tool) => tool?.sandboxOnly);
|
|
74
|
+
};
|
|
75
|
+
/** The refusal of an agentic definition that names no place (noPlaceIssue), at its create or at an edit that would
|
|
76
|
+
* save it, where it would be given the default box (it names no tools, `tools` undefined, so it would get a shell, or a
|
|
77
|
+
* tool that runs only in a box) and this server does not have Docker's box, and where the runner has no shell
|
|
78
|
+
* (`runnerShell` false: Mode 1). On Mode 2 the runner's exec is a shell, and such a definition saves for the runner as
|
|
79
|
+
* it always did, its tools checked there (runnable.ts). Undefined for one that saves. */
|
|
80
|
+
export function noBoxRefusal(tools, registry, flags, runnerShell) {
|
|
81
|
+
if (runnerShell || !wantsBox(tools ?? NEW_AGENT_TOOLS, flags))
|
|
82
|
+
return undefined;
|
|
83
|
+
const fresh = newAgentPlace(registry);
|
|
84
|
+
return "reason" in fresh ? noPlaceIssue(registry) : undefined;
|
|
85
|
+
}
|
|
86
|
+
/** The refusal of a revision that names no place where Docker's box is not here, at definition.place: its words, and
|
|
87
|
+
* what to set as its fix, so no example of a place is picked for it. */
|
|
88
|
+
export const noPlaceIssue = (registry) => ({ field: "definition.place", reason: "missing", message: nameABox(registry), fix: placeToName(registry) });
|
|
56
89
|
/** The tools a new agent in the default box is given when its definition names none: a shell, and the background tools
|
|
57
90
|
* that start, read, feed, signal and list commands that outlive one call (background.ts SHELL_TOOLS, which a test holds
|
|
58
91
|
* this list to; written out here, since background.ts reads this module). A definition that names its tools, an empty
|
|
@@ -80,8 +113,9 @@ export function noBoxReason(registry, listed) {
|
|
|
80
113
|
/** The start banner's words on the boxes: which are ready for a sandbox agent's tools, then why each box is not that
|
|
81
114
|
* AGENTRUN_BOXES lists (`listed`), and, when none is ready, the boxes it does not list, with what to do.
|
|
82
115
|
* `byDefault`, with AGENTRUN_BOXES not set at all: short, the local box alone, said to be on by default, or why it is
|
|
83
|
-
* not
|
|
84
|
-
|
|
116
|
+
* not, and where a new agent with no place goes then: it names its place, or, where the runner has a shell
|
|
117
|
+
* (`runnerShell`: Mode 2), it runs on the runner (placesOf). */
|
|
118
|
+
export function boxesLine(registry, listed, allow = "none", byDefault = false, runnerShell = false) {
|
|
85
119
|
const boxes = boxAvailability(registry);
|
|
86
120
|
const ready = boxes.filter((box) => box.available).map((box) => box.id);
|
|
87
121
|
const said = ready.length ? [`${and(ready)} ${ready.length === 1 ? "is" : "are"} ready, so sandbox agents run their tools there.`] : [];
|
|
@@ -94,17 +128,21 @@ export function boxesLine(registry, listed, allow = "none", byDefault = false) {
|
|
|
94
128
|
if (byDefault) {
|
|
95
129
|
const box = defaultBox(registry);
|
|
96
130
|
if (!box?.available)
|
|
97
|
-
return `Boxes: none, so new agents run on the runner. ${sentence(box?.reason ??
|
|
98
|
-
return [`Boxes: ${box.id} (on by default; set ${BOXES_ENV} to change).`, ...reach].join(" ");
|
|
131
|
+
return `Boxes: none, so ${runnerShell ? "new agents run on the runner" : "a new agent must name its place: a box, or the runner"}. ${sentence(box?.reason ?? NO_REASON)}`;
|
|
132
|
+
return [`Boxes: ${box.id} (on by default; set ${BOXES_ENV} to change).`, ...(runnerShell ? [`New agents run on the runner: Mode 2 keeps workspaces on Archil, which the ${box.id} box can't mount.`] : []), ...reach].join(" ");
|
|
99
133
|
}
|
|
100
134
|
return ["Boxes:", ...(none ? ["none is ready, so sandbox agents do not run here."] : said), ...reach, ...why.map((box) => sentence(`${box.id}: ${box.reason ?? "not available"}`)), ...(rest ? [sentence(rest)] : [])].join(" ");
|
|
101
135
|
}
|
|
102
136
|
/** `places` in capabilities: the modes a revision may name, the place a new agent is saved with and a revision that
|
|
103
|
-
* names none runs in (`default_place
|
|
104
|
-
*
|
|
105
|
-
|
|
137
|
+
* names none runs in (`default_place`), each box, and the hosts a box whose `network` is `allowlist` reaches (`allow`,
|
|
138
|
+
* box-settings.ts boxAllowOf; empty for `none`). `default_place` is the runner where it has a shell (`runnerShell`:
|
|
139
|
+
* Mode 2's Archil exec), Docker answering or not (defaultPlaceOf); else Docker's box where this server has it; else
|
|
140
|
+
* null, no default: a new agent names its place, and `default_reason` is the words a no-place create is refused in
|
|
141
|
+
* (noBoxRefusal). `default_reason` is there exactly when `default_place` is null. */
|
|
142
|
+
export const placesOf = (registry, allow = "none", runnerShell = false) => {
|
|
106
143
|
const fresh = newAgentPlace(registry);
|
|
107
|
-
|
|
144
|
+
const byDefault = runnerShell ? { default_place: { mode: "runner" } } : "place" in fresh ? { default_place: fresh.place } : { default_place: null, default_reason: fresh.reason };
|
|
145
|
+
return { modes: [...PLACE_MODES], ...byDefault, boxes: boxAvailability(registry).map(stated), allow: allow === "none" ? [] : [...allow] };
|
|
108
146
|
};
|
|
109
147
|
/** A box with its state, `ready` when it is available and `unavailable` when not; and, on an available box, its network as the server set it, with
|
|
110
148
|
* `network_reason` when it is none for a cause of its own. */
|
package/dist/print.js
CHANGED
|
@@ -16,7 +16,7 @@ export function banner(o) {
|
|
|
16
16
|
`AGENTRUN_API_KEY=${key}`,
|
|
17
17
|
...(o.tokenIds && (o.tokenIds.length > 1 || o.source === "list") ? [`API tokens taken (ids): ${o.tokenIds.join(", ")}`] : []),
|
|
18
18
|
o.apiOnly
|
|
19
|
-
? "API only (AGENTRUN_API_ONLY=1): the run and deploy routes, the MCP server names, a Composio server's save, a per_run server's save at an origin AGENTRUN_API_ONLY_MCP_ORIGINS lists and a server's delete are served; the console, sign-in, setup, other settings, the MCP endpoint,
|
|
19
|
+
? "API only (AGENTRUN_API_ONLY=1): the run and deploy routes, a trigger's reads and its turn on or off, the MCP server names, a Composio server's save, a per_run server's save at an origin AGENTRUN_API_ONLY_MCP_ORIGINS lists and a server's delete are served; the console, sign-in, setup, other settings, the MCP endpoint, the other trigger routes and hooks are refused."
|
|
20
20
|
: o.accounts || o.launchCode === undefined ? `Open ${o.publicUrl ?? o.url}/` : `Open ${o.publicUrl ?? o.url}/?launch=${o.launchCode}`,
|
|
21
21
|
...(o.boxes ? [o.boxes] : []),
|
|
22
22
|
];
|
|
@@ -1,40 +1,7 @@
|
|
|
1
1
|
import { ApiError } from "./errors.js";
|
|
2
|
-
import { type LearningFolder, type SnapChange, type Snapshot } from "./learn/folder.js";
|
|
3
|
-
import type { PromotionRecord, Refused } from "./learn/promote.js";
|
|
4
2
|
import type { RunRow, Store } from "./store/index.js";
|
|
5
|
-
import type { Workspace } from "./workspace/index.js";
|
|
6
3
|
/** 410 purged for a route of a purged run (Runs.purge): its tombstone, what is kept of it. `tools_usd`: its paid tools'
|
|
7
4
|
* meter as /usage read it at its purge (null: unknown, or none read). */
|
|
8
5
|
export declare function purgedRun(row: RunRow): ApiError;
|
|
9
6
|
/** Which of `runIds` are purged, each with its row: by its row's purge time. One store read per run. */
|
|
10
7
|
export declare function purgedRows(store: Pick<Store, "runs">, runIds: Iterable<string>): Promise<ReadonlyMap<string, RunRow>>;
|
|
11
|
-
/** The one gate every read of the learning folder at a commit goes through, main's or a past commit's (learn/folder.ts
|
|
12
|
-
* snapshotAt, folderAt): the view, the log and a workflow's revisions, a merge's diff, a run's seed (learning.ts seedAt)
|
|
13
|
-
* and the champion read by digest, an SDK start's receipt, and a compile ask (runner/learning-end.ts compileAskOf).
|
|
14
|
-
* `workflows`: each learned workflow of `snapshot` whose workflow.json a purged run wrote (SnapLearned.run: the run of
|
|
15
|
-
* the newest commit that changed the file, over main's whole history, which a purge's put-back hands to the run that
|
|
16
|
-
* wrote those bytes), by name, with that run's row; no read lays, checks, replays, serves or shows it. `served`, read
|
|
17
|
-
* only when `log` is asked: whether a change of the snapshot's log is served (no purged run's merge is), so a log the
|
|
18
|
-
* folder rebuilds names one and still serves none. */
|
|
19
|
-
export declare function purgeGate(snapshot: Snapshot | undefined, store: Pick<Store, "runs">, log?: boolean): Promise<{
|
|
20
|
-
workflows: ReadonlyMap<string, RunRow>;
|
|
21
|
-
served: (change: SnapChange) => boolean;
|
|
22
|
-
}>;
|
|
23
|
-
/** The promotion records of `workflows` that championOf skips (learn/promote.ts Refused), read through purgeGate at
|
|
24
|
-
* each record's commit of the learning folder at `ws`: newest promotion first, whatever its digest's newest decision
|
|
25
|
-
* (a champion held since included: skipping it may leave an earlier one serving), one the gate refuses at its commit (a
|
|
26
|
-
* purged run wrote its workflow there) is skipped with every record of its workflow at that commit (by workflow and
|
|
27
|
-
* commit, so a copy of the records read later is skipped alike, a hold of it included), until the newest promotion left
|
|
28
|
-
* is one the gate lets through, or none is left. The holds are walked the same way, newest first: a hold at a commit the
|
|
29
|
-
* gate refuses (a check that ended after its revision's run was purged holds it there) is skipped with its commit's
|
|
30
|
-
* records, until the newest hold left is one the gate lets through, so the compile's held names (learn/compile.ts
|
|
31
|
-
* heldNamesOf) never ask a revision of a purged run's text. A record with no commit is let through, and so is a commit
|
|
32
|
-
* the folder no longer has (reading its text fails on its own). A commit whose read throws refuses none here and is said
|
|
33
|
-
* (Refused.unread), so the promotions trim trims nothing on it (recordPromotion); a store read of the gate's that throws
|
|
34
|
-
* throws, so every write that asks fails closed. One read-only exec per commit asked. */
|
|
35
|
-
export declare function refusedOf(records: readonly PromotionRecord[], workflows: Iterable<string>, ws: Workspace, store: Pick<Store, "runs">): Promise<Refused>;
|
|
36
|
-
/** refusedOf in the learning folder `folder` opens for each ask (ended after it), over `workflows` (every workflow of
|
|
37
|
-
* the records when absent): the port a champion's readers and the promotions trim ask (runner/promotion.ts
|
|
38
|
-
* PromotionDeps refused, learn/promote.ts recordPromotion). An end() that throws is said to `log` (when given) and never
|
|
39
|
-
* fails the ask: the answer was read. */
|
|
40
|
-
export declare const refusedIn: (folder: () => Pick<LearningFolder, "workspace" | "end">, store: Pick<Store, "runs">, log?: (line: string) => void) => (records: readonly PromotionRecord[], workflows?: Iterable<string>) => Promise<Refused>;
|
package/dist/purged-workflow.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
// What a purged run (DELETE /v2/runs/{id}, agent-delete.ts purgeRun) answers
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
// never served or executed and none of its merges is shown.
|
|
1
|
+
// What a purged run (DELETE /v2/runs/{id}, agent-delete.ts purgeRun) answers. Its learned text needs no rule here: its
|
|
2
|
+
// purge deletes its learning rows (Store.learning purgeRun), so the version before its own serves again and none of its
|
|
3
|
+
// saves is shown.
|
|
5
4
|
import { ApiError } from "./errors.js";
|
|
6
|
-
import { snapshotAt } from "./learn/folder.js";
|
|
7
5
|
const isoOrNull = (ms) => (ms === null ? null : new Date(ms).toISOString());
|
|
8
6
|
/** 410 purged for a route of a purged run (Runs.purge): its tombstone, what is kept of it. `tools_usd`: its paid tools'
|
|
9
7
|
* meter as /usage read it at its purge (null: unknown, or none read). */
|
|
@@ -22,69 +20,3 @@ export async function purgedRows(store, runIds) {
|
|
|
22
20
|
const rows = await Promise.all([...new Set(runIds)].map((run) => store.runs.get(run)));
|
|
23
21
|
return new Map(rows.flatMap((row) => (row && row.purgedAt !== null ? [[row.id, row]] : [])));
|
|
24
22
|
}
|
|
25
|
-
/** The one gate every read of the learning folder at a commit goes through, main's or a past commit's (learn/folder.ts
|
|
26
|
-
* snapshotAt, folderAt): the view, the log and a workflow's revisions, a merge's diff, a run's seed (learning.ts seedAt)
|
|
27
|
-
* and the champion read by digest, an SDK start's receipt, and a compile ask (runner/learning-end.ts compileAskOf).
|
|
28
|
-
* `workflows`: each learned workflow of `snapshot` whose workflow.json a purged run wrote (SnapLearned.run: the run of
|
|
29
|
-
* the newest commit that changed the file, over main's whole history, which a purge's put-back hands to the run that
|
|
30
|
-
* wrote those bytes), by name, with that run's row; no read lays, checks, replays, serves or shows it. `served`, read
|
|
31
|
-
* only when `log` is asked: whether a change of the snapshot's log is served (no purged run's merge is), so a log the
|
|
32
|
-
* folder rebuilds names one and still serves none. */
|
|
33
|
-
export async function purgeGate(snapshot, store, log = false) {
|
|
34
|
-
const writers = new Map((snapshot?.workflows ?? []).flatMap((item) => (item.run ? [[item.name, item.run]] : [])));
|
|
35
|
-
const logged = log ? (snapshot?.log ?? []).flatMap(({ by }) => ("run" in by ? [by.run] : [])) : [];
|
|
36
|
-
const purged = await purgedRows(store, [...writers.values(), ...logged]);
|
|
37
|
-
const workflows = new Map([...writers].flatMap(([name, run]) => (purged.has(run) ? [[name, purged.get(run)]] : [])));
|
|
38
|
-
return {
|
|
39
|
-
workflows,
|
|
40
|
-
served: ({ by }) => {
|
|
41
|
-
if (!log)
|
|
42
|
-
throw new Error("the purge gate was not asked for the log");
|
|
43
|
-
return !("run" in by && purged.has(by.run));
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
/** The promotion records of `workflows` that championOf skips (learn/promote.ts Refused), read through purgeGate at
|
|
48
|
-
* each record's commit of the learning folder at `ws`: newest promotion first, whatever its digest's newest decision
|
|
49
|
-
* (a champion held since included: skipping it may leave an earlier one serving), one the gate refuses at its commit (a
|
|
50
|
-
* purged run wrote its workflow there) is skipped with every record of its workflow at that commit (by workflow and
|
|
51
|
-
* commit, so a copy of the records read later is skipped alike, a hold of it included), until the newest promotion left
|
|
52
|
-
* is one the gate lets through, or none is left. The holds are walked the same way, newest first: a hold at a commit the
|
|
53
|
-
* gate refuses (a check that ended after its revision's run was purged holds it there) is skipped with its commit's
|
|
54
|
-
* records, until the newest hold left is one the gate lets through, so the compile's held names (learn/compile.ts
|
|
55
|
-
* heldNamesOf) never ask a revision of a purged run's text. A record with no commit is let through, and so is a commit
|
|
56
|
-
* the folder no longer has (reading its text fails on its own). A commit whose read throws refuses none here and is said
|
|
57
|
-
* (Refused.unread), so the promotions trim trims nothing on it (recordPromotion); a store read of the gate's that throws
|
|
58
|
-
* throws, so every write that asks fails closed. One read-only exec per commit asked. */
|
|
59
|
-
export async function refusedOf(records, workflows, ws, store) {
|
|
60
|
-
const refused = new Set();
|
|
61
|
-
const skip = (one) => one.commit !== undefined && refused.has(`${one.workflow}\0${one.commit}`);
|
|
62
|
-
let unread = false;
|
|
63
|
-
const reads = new Map();
|
|
64
|
-
const gated = (commit) => reads.get(commit) ?? reads.set(commit, snapshotAt(ws, commit).then(async (at) => (await purgeGate(at, store)).workflows, () => {
|
|
65
|
-
unread = true;
|
|
66
|
-
return new Map();
|
|
67
|
-
})).get(commit);
|
|
68
|
-
const newestOf = (workflow, decided) => records.findLast((one) => one.workflow === workflow && one.decided === decided && !skip(one));
|
|
69
|
-
for (const workflow of new Set(workflows)) {
|
|
70
|
-
for (const decided of ["promote", "hold"]) {
|
|
71
|
-
for (let last = newestOf(workflow, decided); last?.commit && (await gated(last.commit)).has(workflow); last = newestOf(workflow, decided)) {
|
|
72
|
-
refused.add(`${workflow}\0${last.commit}`);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return Object.assign(skip, { unread });
|
|
77
|
-
}
|
|
78
|
-
/** refusedOf in the learning folder `folder` opens for each ask (ended after it), over `workflows` (every workflow of
|
|
79
|
-
* the records when absent): the port a champion's readers and the promotions trim ask (runner/promotion.ts
|
|
80
|
-
* PromotionDeps refused, learn/promote.ts recordPromotion). An end() that throws is said to `log` (when given) and never
|
|
81
|
-
* fails the ask: the answer was read. */
|
|
82
|
-
export const refusedIn = (folder, store, log) => async (records, workflows) => {
|
|
83
|
-
const { workspace, end } = folder();
|
|
84
|
-
try {
|
|
85
|
-
return await refusedOf(records, workflows ?? records.map((one) => one.workflow), workspace, store);
|
|
86
|
-
}
|
|
87
|
-
finally {
|
|
88
|
-
await end().catch((error) => log?.(`learning: the learning folder did not end after the purge gate's ask: ${error instanceof Error ? error.message : String(error)}`));
|
|
89
|
-
}
|
|
90
|
-
};
|
package/dist/redact/match.d.ts
CHANGED
|
@@ -70,13 +70,34 @@ export type Needles = {
|
|
|
70
70
|
export declare function merged(found: readonly (readonly [number, number])[]): Span[];
|
|
71
71
|
/** `text` with each of `spans` (merged, in order) replaced by "[redacted]". */
|
|
72
72
|
export declare function cutAt(text: string, spans: readonly Span[]): string;
|
|
73
|
+
/** What ends each pass of a join (joinOf). Every view keeps it, and no needle holds it, so no held value reads across
|
|
74
|
+
* it. It cannot be a NUL, as the views drop control characters wherever they come from (the text, or an escape or an
|
|
75
|
+
* encoding that decodes to one), and a separator they dropped would join the passes. It is U+FFFF, a noncharacter:
|
|
76
|
+
* squeeze, which every plain and joined needle is made with, drops it, and a hex, folded or base64 needle is ASCII.
|
|
77
|
+
* Only the one joinOf puts there separates. One the text brought shows as a box at most, and a reader reads a held
|
|
78
|
+
* value through it, so the views drop it as they drop a control character, as it stands or as a decoder made it, and
|
|
79
|
+
* joinOf reads one in a part's text as a NUL (one character for one, so every offset stays, and dropped too). A
|
|
80
|
+
* caller that marks places in a text with its own (secret-cut.ts) asks holds for `separated`. */
|
|
81
|
+
export declare const SEPARATOR = "\uFFFF";
|
|
73
82
|
/** `text` as a view reads it, and as a held value's needles are read: decomposed (NFKD), its combining marks dropped,
|
|
74
83
|
* then NFKC, with its whitespace and its characters that render as nothing gone, before (so one between a letter and
|
|
75
84
|
* its accent hides neither) and after. A held value with a zero-width space or a soft hyphen between its characters
|
|
76
|
-
* reads as itself
|
|
85
|
+
* reads as itself, and so does one with a control character between them (a NUL, an escape); so does one with a
|
|
86
|
+
* combining mark after a letter, which NFKC alone composes into another letter
|
|
77
87
|
* ("Z" and U+0301 into "Ź"), and one written with a precomposed letter in place of its own ("Ź" for "Z"). A held
|
|
78
|
-
* value's accents are dropped the same way, so it reads as itself with them or without: more cutting, never less.
|
|
88
|
+
* value's accents are dropped the same way, so it reads as itself with them or without: more cutting, never less.
|
|
89
|
+
* SEPARATOR goes too, so no needle holds it (a join's view keeps it, never squeezing it). */
|
|
79
90
|
export declare const squeeze: (text: string) => string;
|
|
91
|
+
/** One of Python's own escapes at `at`, as its repr writes a str: an escaped apostrophe ("\'", in a string that holds
|
|
92
|
+
* both quotes) is an apostrophe, "\x" and two hex digits the character they number; with `levels` 2, either written
|
|
93
|
+
* once more as a JSON string's text too ("\\'", "\\x41": a dict a model wrote in a call's arguments, read one level
|
|
94
|
+
* down). The character and where it ends; undefined where none starts. It reads at most five characters. key-refusal.ts's
|
|
95
|
+
* peek counts an escape by it (both levels), so the read past a call's stop counts "\x20" as the views that read
|
|
96
|
+
* Python's escapes do: a space. */
|
|
97
|
+
export declare function pythonEscapeAt(text: string, at: number, levels?: 1 | 2): {
|
|
98
|
+
char: string;
|
|
99
|
+
end: number;
|
|
100
|
+
} | undefined;
|
|
80
101
|
/** What JSON_ESCAPE reads at `at`: the character the escape there decodes to, through both levels ("" for an escaped
|
|
81
102
|
* quote, which decodes to nothing), and where it ends; undefined where no escape starts (the "\" is then itself).
|
|
82
103
|
* key-refusal.ts's peek counts an escape by it, so the read past a call's stop and the JSON view see the same
|
|
@@ -85,10 +106,15 @@ export declare function jsonEscapeAt(text: string, at: number): {
|
|
|
85
106
|
char: string;
|
|
86
107
|
end: number;
|
|
87
108
|
} | undefined;
|
|
88
|
-
/** The character an HTML
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
109
|
+
/** The character an HTML character reference at `at` stands for, as a browser reads one in text, and where it ends:
|
|
110
|
+
* - a named one of NAMED, with its ";" ("&" is "&"); it reads at most 6 characters;
|
|
111
|
+
* - a numeric one: "&#" and decimal digits, or "&#x" or "&#X" and hex digits, any zeros first (read as nothing:
|
|
112
|
+
* "A" is "A"), then at most 7 decimal or 6 hex digits, then ";" or not (a browser reads "A" before a letter
|
|
113
|
+
* as "A" too). It reads its zeros and one digit past the most, each once and counted: a run of zeros is read again
|
|
114
|
+
* only by the view that copies it where no reference stands.
|
|
115
|
+
* Undefined where none starts, or it stands for no character (zero, a surrogate, past U+10FFFF, or more digits than
|
|
116
|
+
* that). key-refusal.ts's peek counts a reference by it, so the read past a call's stop and the views see the same
|
|
117
|
+
* characters. */
|
|
92
118
|
export declare function entityAt(text: string, at: number): {
|
|
93
119
|
char: string;
|
|
94
120
|
end: number;
|
|
@@ -97,10 +123,12 @@ export declare function entityAt(text: string, at: number): {
|
|
|
97
123
|
* form encoded, an NFKC variant, its hex in any case, a hex identifier folded (`fold`), split across two strings of a
|
|
98
124
|
* JSON text (joinOf; a "+" after its head or a quote of its own in it too), or split there at its own "," or ":"
|
|
99
125
|
* (`joined`). With `cuts`, a value whose every character the view read comes from inside the cuts is not held: it is
|
|
100
|
-
* cut in place.
|
|
101
|
-
|
|
126
|
+
* cut in place. A U+FFFF in `text` is nothing to the views (SEPARATOR); with `separated`, each one is the caller's
|
|
127
|
+
* mark and separates there in every view. */
|
|
128
|
+
export declare function holds(text: string, needles: Needles, { fold, cuts, separated }?: {
|
|
102
129
|
fold?: boolean;
|
|
103
130
|
cuts?: readonly Span[];
|
|
131
|
+
separated?: boolean;
|
|
104
132
|
}): boolean;
|
|
105
133
|
/** planCut's first step: every form, hex, folded identifier and shape of `text` as it came, and `held`, merged. */
|
|
106
134
|
export declare function cutSpans(text: string, needles: Needles, shapes: readonly Shape[], held?: readonly (readonly [number, number])[]): Span[];
|