@arcforge/platform 2.0.166
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/README.md +31 -0
- package/package.json +69 -0
- package/src/bin/supervisor.ts +102 -0
- package/src/bin/test-api.ts +30 -0
- package/src/bin/test-preload.ts +308 -0
- package/src/bin/update-helper.ts +32 -0
- package/src/build/bench/CLAUDE.md +106 -0
- package/src/build/bench/SPEC.md +209 -0
- package/src/build/bench/agents.ts +105 -0
- package/src/build/bench/axes.ts +84 -0
- package/src/build/bench/bench.ts +96 -0
- package/src/build/bench/discover.ts +147 -0
- package/src/build/bench/index.ts +7 -0
- package/src/build/bench/log.ts +47 -0
- package/src/build/bench/matrix.ts +23 -0
- package/src/build/bench/preload.ts +440 -0
- package/src/build/bench/prepare.ts +61 -0
- package/src/build/bench/projection.ts +112 -0
- package/src/build/bench/resolve.ts +54 -0
- package/src/build/bench/runner.ts +309 -0
- package/src/build/bench/schema/extract.ts +148 -0
- package/src/build/bench/schema/index.ts +2 -0
- package/src/build/bench/schema/schema.ts +95 -0
- package/src/build/bench/schema/worker.ts +30 -0
- package/src/build/bench/typegen.ts +119 -0
- package/src/build/bench/workspace/files.ts +139 -0
- package/src/build/bench/workspace/handle.ts +133 -0
- package/src/build/bench/workspace/index.ts +11 -0
- package/src/build/bench/workspace/workspace.ts +14 -0
- package/src/build/blueprint/blueprint.ts +398 -0
- package/src/build/blueprint/cognet/abi.ts +207 -0
- package/src/build/blueprint/cognet/bundle-worker.ts +93 -0
- package/src/build/blueprint/cognet/bundle.ts +664 -0
- package/src/build/blueprint/cognet/cognet.ts +249 -0
- package/src/build/blueprint/cognet/index.ts +10 -0
- package/src/build/blueprint/cognet/manifest.ts +38 -0
- package/src/build/blueprint/cognet/resolve.ts +113 -0
- package/src/build/blueprint/collisions.ts +51 -0
- package/src/build/blueprint/index.ts +29 -0
- package/src/build/blueprint/modules/entries.ts +117 -0
- package/src/build/blueprint/modules/index.ts +300 -0
- package/src/build/blueprint/modules/meta.ts +174 -0
- package/src/build/blueprint/scan/boot.ts +34 -0
- package/src/build/blueprint/scan/cognetImports.ts +56 -0
- package/src/build/blueprint/scan/components.ts +45 -0
- package/src/build/blueprint/scan/config.ts +234 -0
- package/src/build/blueprint/scan/configImports.ts +232 -0
- package/src/build/blueprint/scan/declare-worker.ts +61 -0
- package/src/build/blueprint/scan/declare.ts +393 -0
- package/src/build/blueprint/scan/h3-globals.ts +137 -0
- package/src/build/blueprint/scan/knowledge.ts +101 -0
- package/src/build/blueprint/scan/middleware.ts +110 -0
- package/src/build/blueprint/scan/moduleImports.ts +79 -0
- package/src/build/blueprint/scan/plugins.ts +93 -0
- package/src/build/blueprint/scan/promptPackages.ts +45 -0
- package/src/build/blueprint/scan/prompts.ts +164 -0
- package/src/build/blueprint/scan/published.ts +131 -0
- package/src/build/blueprint/scan/resolve.ts +398 -0
- package/src/build/blueprint/scan/routes.ts +109 -0
- package/src/build/blueprint/scan/scripts.ts +119 -0
- package/src/build/blueprint/scan/tool-bundle-worker.ts +69 -0
- package/src/build/blueprint/scan/tools.ts +610 -0
- package/src/build/blueprint/types.ts +28 -0
- package/src/build/extensions/config.ts +261 -0
- package/src/build/extensions/edit.ts +684 -0
- package/src/build/extensions/extensions.ts +731 -0
- package/src/build/extensions/index.ts +10 -0
- package/src/build/extensions/load.ts +350 -0
- package/src/build/extensions/registrations.ts +189 -0
- package/src/build/extensions/store.ts +200 -0
- package/src/build/frame/frame.ts +145 -0
- package/src/build/frame/index.ts +5 -0
- package/src/build/frame/migrate.ts +246 -0
- package/src/build/project/bundle/agent.ts +382 -0
- package/src/build/project/bundle/artifacts.ts +88 -0
- package/src/build/project/bundle/assets.ts +385 -0
- package/src/build/project/bundle/bundle.ts +160 -0
- package/src/build/project/bundle/imports.ts +102 -0
- package/src/build/project/bundle/index.ts +16 -0
- package/src/build/project/bundle/module.ts +130 -0
- package/src/build/project/bundle/source.ts +136 -0
- package/src/build/project/bundle/stage.ts +97 -0
- package/src/build/project/bundle/types.ts +111 -0
- package/src/build/project/cognet.ts +156 -0
- package/src/build/project/create/agent.ts +52 -0
- package/src/build/project/create/bench.ts +81 -0
- package/src/build/project/create/cognet.ts +102 -0
- package/src/build/project/create/extension.ts +63 -0
- package/src/build/project/create/module.ts +43 -0
- package/src/build/project/create/profile.ts +102 -0
- package/src/build/project/create/prompt.ts +68 -0
- package/src/build/project/create/templates.ts +88 -0
- package/src/build/project/deploy.ts +96 -0
- package/src/build/project/index.ts +40 -0
- package/src/build/project/installer.ts +616 -0
- package/src/build/project/kinds.ts +374 -0
- package/src/build/project/links.ts +33 -0
- package/src/build/project/manifest/bunfig.ts +139 -0
- package/src/build/project/manifest/config.ts +246 -0
- package/src/build/project/manifest/env.ts +184 -0
- package/src/build/project/manifest/index.ts +9 -0
- package/src/build/project/manifest/manifest.ts +49 -0
- package/src/build/project/manifest/model.ts +124 -0
- package/src/build/project/manifest/package.ts +386 -0
- package/src/build/project/manifest/text.ts +19 -0
- package/src/build/project/models/fetch.ts +123 -0
- package/src/build/project/models/index.ts +8 -0
- package/src/build/project/models/models.ts +111 -0
- package/src/build/project/models/specifier.ts +106 -0
- package/src/build/project/models/store.ts +202 -0
- package/src/build/project/modules/hash.ts +31 -0
- package/src/build/project/modules/index.ts +5 -0
- package/src/build/project/modules/lock.ts +78 -0
- package/src/build/project/modules/modules.ts +155 -0
- package/src/build/project/prepare.ts +709 -0
- package/src/build/project/project.ts +253 -0
- package/src/build/project/projects.ts +164 -0
- package/src/build/project/propagation.ts +120 -0
- package/src/build/project/publish/verify.ts +312 -0
- package/src/build/project/publish.ts +155 -0
- package/src/build/project/reconcile.ts +93 -0
- package/src/build/project/specifier.ts +42 -0
- package/src/build/project/tree.ts +615 -0
- package/src/build/project/treecache.ts +356 -0
- package/src/build/project/typegen/axon-dts.ts +362 -0
- package/src/build/project/typegen/cognet-dts.ts +91 -0
- package/src/build/project/typegen/components.ts +45 -0
- package/src/build/project/typegen/env.ts +59 -0
- package/src/build/project/typegen/generators.ts +108 -0
- package/src/build/project/typegen/hooks.ts +71 -0
- package/src/build/project/typegen/index.ts +137 -0
- package/src/build/project/typegen/prompt-dts.ts +40 -0
- package/src/build/project/typegen/prompts.ts +36 -0
- package/src/build/project/typegen/registry-dts.ts +109 -0
- package/src/build/project/typegen/scripts.ts +37 -0
- package/src/build/project/typegen/tools.ts +31 -0
- package/src/build/project/typegen/tsconfig.ts +243 -0
- package/src/build/project/typegen/tui-dts.ts +120 -0
- package/src/build/project/typegen/write.ts +40 -0
- package/src/build/project/verify.ts +268 -0
- package/src/build/project/watcher.ts +266 -0
- package/src/build/runtime/agent.ts +550 -0
- package/src/build/runtime/escalations.ts +159 -0
- package/src/build/runtime/index.ts +15 -0
- package/src/build/runtime/instances.ts +604 -0
- package/src/build/runtime/profile.ts +91 -0
- package/src/build/runtime/progress.ts +143 -0
- package/src/build/runtime/requests.ts +167 -0
- package/src/build/runtime/resolve.ts +159 -0
- package/src/build/runtime/runtime.ts +233 -0
- package/src/build/runtime/sessions/index.ts +5 -0
- package/src/build/runtime/sessions/record.ts +145 -0
- package/src/build/runtime/sessions/sessions.ts +240 -0
- package/src/build/runtime/zeno.ts +120 -0
- package/src/index.ts +11 -0
- package/src/link/agent-main.ts +395 -0
- package/src/link/index.ts +70 -0
- package/src/link/services.ts +120 -0
- package/src/platform.ts +293 -0
- package/src/procs/index.ts +15 -0
- package/src/procs/tree.ts +177 -0
- package/src/services/cloud.ts +419 -0
- package/src/services/control/client.ts +126 -0
- package/src/services/control/dispatch.ts +156 -0
- package/src/services/control/index.ts +17 -0
- package/src/services/control/protocol.ts +179 -0
- package/src/services/control/server.ts +241 -0
- package/src/services/deployments.ts +81 -0
- package/src/services/files.ts +329 -0
- package/src/services/index.ts +5 -0
- package/src/services/mic/capture.ts +248 -0
- package/src/services/mic/config.ts +109 -0
- package/src/services/mic/fft.ts +93 -0
- package/src/services/mic/index.ts +139 -0
- package/src/services/mic/visualizer.ts +46 -0
- package/src/services/ollama/catalog.ts +122 -0
- package/src/services/ollama/http.ts +124 -0
- package/src/services/ollama/index.ts +13 -0
- package/src/services/ollama/models.ts +153 -0
- package/src/services/ollama/ollama.ts +89 -0
- package/src/services/ollama/registry.ts +112 -0
- package/src/services/ollama/types.ts +72 -0
- package/src/services/prompts.ts +76 -0
- package/src/services/registry.ts +220 -0
- package/src/services/resources/hardware.ts +125 -0
- package/src/services/resources/index.ts +6 -0
- package/src/services/resources/reservations.ts +162 -0
- package/src/services/resources/resources.ts +156 -0
- package/src/services/running/index.ts +1 -0
- package/src/services/running/running.ts +200 -0
- package/src/services/store/disk.ts +97 -0
- package/src/services/store/index.ts +15 -0
- package/src/services/store/store.ts +729 -0
- package/src/services/store/types.ts +303 -0
- package/src/services/test/child.ts +150 -0
- package/src/services/test/events.ts +102 -0
- package/src/services/test/files.ts +26 -0
- package/src/services/test/frames.ts +39 -0
- package/src/services/test/index.ts +7 -0
- package/src/services/test/runner.ts +122 -0
- package/src/services/test/types.ts +26 -0
- package/src/services/update/contract.ts +77 -0
- package/src/services/update/index.ts +12 -0
- package/src/services/update/installer.ts +139 -0
- package/src/services/update/updates.ts +137 -0
- package/src/utils/fs.ts +148 -0
- package/src/utils/tsast.ts +102 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import type { EscalationCall } from "@arcforge/types"
|
|
2
|
+
import type { StoreT } from "../../services/store"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A surface that can answer an escalation — the TUI, the CLI, Fleet.
|
|
6
|
+
*
|
|
7
|
+
* Registered rather than injected because WHICH surface is listening changes
|
|
8
|
+
* at runtime: the TUI attaches when it boots and detaches on exit, while a
|
|
9
|
+
* headless `axon run` never registers one at all. A handler that had to be
|
|
10
|
+
* supplied at construction would make "nobody is listening" unrepresentable,
|
|
11
|
+
* and that is the case this design exists to handle honestly.
|
|
12
|
+
*/
|
|
13
|
+
export type EscalationHandler = (request: {
|
|
14
|
+
/** The store request id — what an answer names, and what a later approval finds. */
|
|
15
|
+
id: string
|
|
16
|
+
agent: string
|
|
17
|
+
sessionId: string
|
|
18
|
+
fn: string
|
|
19
|
+
subject: string
|
|
20
|
+
}) => Promise<boolean>
|
|
21
|
+
|
|
22
|
+
type EscalationsOpts = {
|
|
23
|
+
store: StoreT
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export type EscalationsT = ReturnType<typeof Escalations>
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Escalations — the platform's answer to "may I?".
|
|
30
|
+
*
|
|
31
|
+
* A sibling of Requests() rather than a method on it: that owns subagent
|
|
32
|
+
* spawning, this owns policy decisions, and one object holding both would be
|
|
33
|
+
* two concerns sharing a name.
|
|
34
|
+
*
|
|
35
|
+
* ── Three outcomes, and only one of them asks a human ────────────────────────
|
|
36
|
+
*
|
|
37
|
+
* 1. A GRANT covers it → allow, silently, no prompt and no wait.
|
|
38
|
+
* 2. A SURFACE is attached → prompt, and wait for the answer.
|
|
39
|
+
* 3. NOTHING is attached → deny immediately.
|
|
40
|
+
*
|
|
41
|
+
* (3) is the one worth stating. The capsule's own fallback is a 30-second
|
|
42
|
+
* timeout, which turns every escalation in a headless run — CI, a cron, a
|
|
43
|
+
* deployment — into a 30-second stall before the same denial. Failing fast is
|
|
44
|
+
* both quicker and more honest: the request is recorded, the call gets a
|
|
45
|
+
* denial naming it, and approving it later writes a grant the NEXT attempt
|
|
46
|
+
* reads. "Answer later" cannot mean "the call waits" — the wake is blocked
|
|
47
|
+
* inside a tool call, and parking that for hours would freeze the agent
|
|
48
|
+
* mid-turn holding a capsule and a run.
|
|
49
|
+
*
|
|
50
|
+
* ── Every request is recorded, answered or not ──────────────────────────────
|
|
51
|
+
*
|
|
52
|
+
* Including the ones a human answers instantly. The log is what makes the
|
|
53
|
+
* decision auditable and what a later approval attaches to; a prompt that
|
|
54
|
+
* resolved without leaving a trace is a capability granted with no record of
|
|
55
|
+
* who granted it.
|
|
56
|
+
*/
|
|
57
|
+
export function Escalations(opts: EscalationsOpts) {
|
|
58
|
+
let handler: EscalationHandler | null = null
|
|
59
|
+
|
|
60
|
+
return {
|
|
61
|
+
/**
|
|
62
|
+
* Attach the surface that answers. Returns a detach function.
|
|
63
|
+
*
|
|
64
|
+
* Last registration wins rather than stacking: two surfaces prompting
|
|
65
|
+
* for one decision would race, and the loser's prompt would linger
|
|
66
|
+
* over a question already answered.
|
|
67
|
+
*/
|
|
68
|
+
handle(next: EscalationHandler): () => void {
|
|
69
|
+
handler = next
|
|
70
|
+
return () => {
|
|
71
|
+
if (handler === next) handler = null
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
/** Whether any surface is currently listening. */
|
|
76
|
+
get attached(): boolean {
|
|
77
|
+
return handler !== null
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Decide one escalation, for the capsule that raised it.
|
|
82
|
+
*
|
|
83
|
+
* `agent` and `sessionId` come from the kernel that owns the capsule —
|
|
84
|
+
* this has no way to know them, and a request that could not name its
|
|
85
|
+
* agent could not be granted to one.
|
|
86
|
+
*/
|
|
87
|
+
async decide(context: { agent: string; sessionId: string }, call: EscalationCall): Promise<boolean> {
|
|
88
|
+
const profile = opts.store.profiles.active()
|
|
89
|
+
const subject = subjectOf(call)
|
|
90
|
+
|
|
91
|
+
// No profile — a headless run outside one. Nothing to consult and
|
|
92
|
+
// nowhere to record, so the capsule's own default stands.
|
|
93
|
+
if (!profile) return false
|
|
94
|
+
|
|
95
|
+
const granted = profile.grants.covers(context.agent, call.fn, subject)
|
|
96
|
+
if (granted) {
|
|
97
|
+
const request = profile.requests.raise({
|
|
98
|
+
agent: context.agent,
|
|
99
|
+
sessionId: context.sessionId,
|
|
100
|
+
fn: call.fn,
|
|
101
|
+
subject,
|
|
102
|
+
})
|
|
103
|
+
profile.requests.settle(request.id, {
|
|
104
|
+
decision: "allow",
|
|
105
|
+
by: "grant",
|
|
106
|
+
at: Date.now(),
|
|
107
|
+
grantId: granted.id,
|
|
108
|
+
})
|
|
109
|
+
return true
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const request = profile.requests.raise({
|
|
113
|
+
agent: context.agent,
|
|
114
|
+
sessionId: context.sessionId,
|
|
115
|
+
fn: call.fn,
|
|
116
|
+
subject,
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
if (!handler) {
|
|
120
|
+
// Recorded as expired rather than denied: nothing refused
|
|
121
|
+
// this, nobody was there. Approving it later writes a grant
|
|
122
|
+
// the next attempt reads.
|
|
123
|
+
profile.requests.settle(request.id, { decision: "deny", by: "expired", at: Date.now() })
|
|
124
|
+
return false
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
try {
|
|
128
|
+
const allowed = await handler({
|
|
129
|
+
id: request.id,
|
|
130
|
+
agent: context.agent,
|
|
131
|
+
sessionId: context.sessionId,
|
|
132
|
+
fn: call.fn,
|
|
133
|
+
subject,
|
|
134
|
+
})
|
|
135
|
+
profile.requests.settle(request.id, { decision: allowed ? "allow" : "deny", by: "user", at: Date.now() })
|
|
136
|
+
return allowed
|
|
137
|
+
} catch {
|
|
138
|
+
// A surface that threw did not decide. Denied — the capsule's
|
|
139
|
+
// posture everywhere — and recorded as expired rather than as
|
|
140
|
+
// a user's choice, because no user made one.
|
|
141
|
+
profile.requests.settle(request.id, { decision: "deny", by: "expired", at: Date.now() })
|
|
142
|
+
return false
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* What the rule was matched against.
|
|
150
|
+
*
|
|
151
|
+
* The mediator evaluates the FIRST string argument — a command, a host, a
|
|
152
|
+
* path — so that is what a grant has to cover. Falling back to the fn name
|
|
153
|
+
* keeps a zero-argument call grantable rather than producing a grant whose
|
|
154
|
+
* subject is empty and matches everything.
|
|
155
|
+
*/
|
|
156
|
+
function subjectOf(call: EscalationCall): string {
|
|
157
|
+
const first = call.args[0]
|
|
158
|
+
return typeof first === "string" && first.length > 0 ? first : call.fn
|
|
159
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// runtime — every agent running on this machine.
|
|
2
|
+
// Runtime() is the module's single entry point.
|
|
3
|
+
|
|
4
|
+
export { Runtime, type RuntimeT } from "./runtime"
|
|
5
|
+
export { Escalations, type EscalationsT, type EscalationHandler } from "./escalations"
|
|
6
|
+
export { Resolve, type ResolveT, type ResolvedAgent, type RefKind } from "./resolve"
|
|
7
|
+
export { isRemote, type InstanceT, type InstanceSource, type RemoteTarget, type SpawnOpts } from "./instances"
|
|
8
|
+
export type { AgentT } from "./agent"
|
|
9
|
+
export { stageFor, unitFor, type BootStage, type BootProgress, type BuildUnit, type UnitTiming } from "./progress"
|
|
10
|
+
export { sessionHasEntries, sessionHead, isListableSession, type SessionRecord, type SessionHead } from "./sessions"
|
|
11
|
+
export { ZENO, type ZenoT } from "./zeno"
|
|
12
|
+
export { Profile, type ProfileT } from "./profile"
|
|
13
|
+
// Sessions() acts on ONE log by path (fork, rename) as well as listing them,
|
|
14
|
+
// so it is reachable on its own rather than only through Runtime().
|
|
15
|
+
export { Sessions, type SessionsT } from "./sessions"
|