@akanjs/cli 3.0.0-beta.3 → 3.0.0-beta.30
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/.build-stamp +1 -1
- package/CodeAgent-xnfyyz8h.js +9 -0
- package/CodeAgentRpcHost-p7h6n2hp.js +7 -0
- package/CodeAgentRpcListener-7p7z5dd7.js +97 -0
- package/CodeTui-h66xb1fh.js +1457 -0
- package/README.md +3 -0
- package/TunnelShare-cwh9ezsm.js +9 -0
- package/{agent.command-d2gfxfck.js → agent.command-c4v7kjff.js} +8 -9
- package/akanCode.js +102 -0
- package/application.command-yzsswrz6.js +241 -0
- package/{applicationBuildRunner-kxwbssgn.js → applicationBuildRunner-qkt6spd5.js} +121 -77
- package/buildBatch.proc.js +120 -32
- package/cloud.command-v8h688jc.js +95 -0
- package/cloud.script-yct1sk4k.js +20 -0
- package/code.command-jff3tw7y.js +154 -0
- package/commandManifest.json +1 -1
- package/consoleToStderr-h5bryj94.js +7 -0
- package/context.command-y5sevk3c.js +48 -0
- package/context.runner-90hsmacr.js +21 -0
- package/{dependencyScanner-shs82ynp.js → dependencyScanner-06z2dmrr.js} +2 -2
- package/{devTui-40ggmd99.js → devTui-q7k7bakd.js} +122 -40
- package/fileSys-wzzrntkw.js +9 -0
- package/guideline.command-11cndccb.js +42 -0
- package/guidelines/agentRule/agentRule.instruction.md +209 -33
- package/guidelines/conventions/conventions.instruction.md +143 -41
- package/guidelines/fieldRule/fieldRule.instruction.md +1 -0
- package/guidelines/mcpRule/mcpRule.instruction.md +7 -5
- package/guidelines/queryRule/queryRule.instruction.md +21 -7
- package/guidelines/runtimeRule/runtimeRule.instruction.md +268 -6
- package/guidelines/ssrRule/ssrRule.instruction.md +4 -2
- package/guidelines/transportRule/transportRule.instruction.md +51 -0
- package/guidelines/workspaceOnboarding/workspaceOnboarding.instruction.md +20 -0
- package/guidelines/workspaceRecipes/workspaceRecipes.instruction.md +66 -3
- package/incrementalBuilder.proc.js +564 -109
- package/{index-fz5q3gd7.js → index-0ncc0mbk.js} +10 -17
- package/index-167c77aq.js +69 -0
- package/{index-kcxmv48c.js → index-2ahj896a.js} +45 -79
- package/index-2wc41k5w.js +49 -0
- package/{index-j9yhg404.js → index-35mmm9ca.js} +4 -7
- package/{index-a64esmtb.js → index-376gpdds.js} +523 -1022
- package/index-3hx1z96c.js +87 -0
- package/{index-v0qh106m.js → index-3rh7thcx.js} +961 -892
- package/{index-hwkygn9s.js → index-48k96p55.js} +325 -36
- package/{index-q0y2jq9j.js → index-52w0fvh8.js} +21 -4
- package/index-5rp0h6na.js +1119 -0
- package/index-6x9p8dpb.js +4300 -0
- package/index-7md2g9vw.js +6 -0
- package/index-8tv7356t.js +700 -0
- package/index-94s080qm.js +266 -0
- package/index-9dp031by.js +12 -0
- package/{index-ws5e0j51.js → index-a4s954kq.js} +43 -26
- package/{index-3d9y066c.js → index-bjwxs904.js} +9 -8
- package/{index-ne2qy0nk.js → index-bxmejydw.js} +12 -12
- package/index-c6eggbee.js +123 -0
- package/index-d2242ksy.js +99 -0
- package/{index-92zztqy1.js → index-dy0jx9ay.js} +2 -17
- package/{index-259dsnz3.js → index-gxamdf18.js} +5 -8
- package/{index-4edzf1gr.js → index-hf6f4xnb.js} +77 -150
- package/{index-by5gpp8x.js → index-hj6w4ka1.js} +2 -1
- package/{index-gyd220p2.js → index-hmdq5pqm.js} +554 -577
- package/{index-600zhnve.js → index-hqd0h1pb.js} +75 -203
- package/index-kb16nzyt.js +997 -0
- package/index-mk3b9rk1.js +2729 -0
- package/{index-2tv3fdx4.js → index-n3jk2501.js} +1205 -1458
- package/index-p6pbz9n5.js +25 -0
- package/{index-zry5nz81.js → index-qcejqgts.js} +51 -30
- package/{index-7737gxcp.js → index-rtwhw4aq.js} +107 -241
- package/{index-pnqbkf5p.js → index-se643zvp.js} +6 -2
- package/index-tsb0f8ya.js +53 -0
- package/{index-ktb5njgy.js → index-tzc1gtrg.js} +49 -99
- package/index-wa5jbxj1.js +760 -0
- package/index-wfwgcnyc.js +187 -0
- package/{index-mak3cd28.js → index-xb7qhxa8.js} +137 -255
- package/{index-h7yw2z9n.js → index-zzvvc845.js} +8 -14
- package/index.js +23 -22
- package/{library.command-nbsky672.js → library.command-n9kp7yms.js} +4 -5
- package/{localRegistry.command-yeq57wjr.js → localRegistry.command-jx6kxt2x.js} +23 -42
- package/{module.command-29vqzrh8.js → module.command-q2xjf6cx.js} +8 -11
- package/{package.command-axv0abmn.js → package.command-q5a3nsw5.js} +6 -7
- package/package.json +15 -7
- package/{page.command-vs9s3zrh.js → page.command-ppenrxjn.js} +4 -5
- package/{primitive.command-cbxmqbtc.js → primitive.command-dvgg8nem.js} +9 -22
- package/prompter-76k56b37.js +8 -0
- package/{quality.command-gmbs7nws.js → quality.command-pz7kg3pc.js} +205 -377
- package/{recipeScanner-fpagtgc1.js → recipeScanner-4b69ybe0.js} +1 -1
- package/{repair.command-bqsjptsj.js → repair.command-a6py9xvz.js} +11 -35
- package/{routeSourceValidator-apyqw7wk.js → routeSourceValidator-7ycnfz0e.js} +0 -6
- package/{scalar.command-6k1vhe9s.js → scalar.command-7f3xfpen.js} +7 -10
- package/skills/akan-code/SKILL.md +130 -0
- package/skills/akan-debug/SKILL.md +42 -0
- package/skills/akan-deps/SKILL.md +50 -0
- package/skills/akan-err/SKILL.md +39 -0
- package/skills/akan-module/SKILL.md +45 -0
- package/skills/akan-scaffold/SKILL.md +76 -0
- package/skills/akan-scalar/SKILL.md +52 -0
- package/skills/akan-service/SKILL.md +34 -0
- package/skills/akan-store/SKILL.md +67 -0
- package/skills/akan-ui/SKILL.md +63 -0
- package/skills/akan-validate/SKILL.md +44 -0
- package/{subspace.command-fwjfcts7.js → subspace.command-z7nqs508.js} +138 -67
- package/templates/__scalar/__model__/__model__.abstract.md.template +8 -0
- package/templates/appSample/lib/__scalar/workHistory/workHistory.abstract.ts +8 -39
- package/templates/appSample/lib/_noti/noti.abstract.ts +6 -29
- package/templates/appSample/lib/task/task.abstract.ts +12 -32
- package/templates/appSample/lib/task/task.signal.spec.ts +15 -18
- package/templates/appSample/lib/task/task.signal.test.ts +15 -1
- package/templates/appSample/lib/task/task.signal.ts +1 -1
- package/templates/appSample/srvkit/{AuthGuard.ts → guards.ts} +7 -4
- package/templates/appSample/srvkit/{SessionInternalArg.ts → internalArgs.ts} +6 -4
- package/templates/client.ts +7 -30
- package/templates/crudPages/[__model__Id]/edit/page.tsx +2 -1
- package/templates/crudPages/[__model__Id]/page.tsx +2 -1
- package/templates/crudPages/new/page.tsx +2 -1
- package/templates/crudPages/page.tsx +2 -1
- package/templates/crudSinglePage/page.tsx +2 -1
- package/templates/lib/__lib/lib.dictionary.ts +0 -2
- package/templates/lib/__lib/lib.document.ts +0 -2
- package/templates/lib/sig.ts +8 -30
- package/templates/localDev/docker-compose.yaml.template +3 -14
- package/templates/module/__model__.signal.ts +12 -4
- package/templates/pkgRoot/tsconfig.json.template +2 -7
- package/templates/server.ts +1 -3
- package/templates/service/__model__.abstract.md.template +8 -0
- package/templates/workspaceRoot/.gitignore.template +0 -1
- package/templates/workspaceRoot/package.json.template +1 -3
- package/tunnel.command-zy4wbcgt.js +129 -0
- package/{typeChecker-3xgrzc2v.js → typeChecker-px49mezc.js} +1 -1
- package/typecheck.proc.js +1 -1
- package/workflow.command-f142t17s.js +79 -0
- package/{workspace.command-8s050m0h.js → workspace.command-gpk1149x.js} +77 -109
- package/abstractCompactor-mjh5ppsq.js +0 -101
- package/application.command-pj2m7584.js +0 -204
- package/applicationReleasePackager-4yasxwv9.js +0 -244
- package/capacitorApp-36rbr858.js +0 -12
- package/cloud.command-jshwdq22.js +0 -93
- package/context.command-ez8a0zyz.js +0 -80
- package/devTuiView-c08ccbat.js +0 -9
- package/getDirname-dr3jz1xg.js +0 -7
- package/guideline.command-xmqwx8zm.js +0 -359
- package/guidelines/agentRule/agentRule.generate.json +0 -31
- package/guidelines/componentRule/componentRule.generate.json +0 -31
- package/guidelines/conventions/conventions.generate.json +0 -25
- package/guidelines/cssRule/cssRule.generate.json +0 -31
- package/guidelines/docPageRule/docPageRule.generate.json +0 -31
- package/guidelines/docPageRule/docPageRule.instruction.md +0 -25
- package/guidelines/docSyncRule/docSyncRule.generate.json +0 -31
- package/guidelines/docSyncRule/docSyncRule.instruction.md +0 -25
- package/guidelines/enumConstant/enumConstant.generate.json +0 -31
- package/guidelines/enumConstant/enumConstant.instruction.md +0 -28
- package/guidelines/fieldRule/fieldRule.generate.json +0 -31
- package/guidelines/framework/framework.generate.json +0 -32
- package/guidelines/mcpRule/mcpRule.generate.json +0 -35
- package/guidelines/modelConstant/modelConstant.generate.json +0 -32
- package/guidelines/modelDictionary/modelDictionary.generate.json +0 -32
- package/guidelines/modelDocument/modelDocument.generate.json +0 -31
- package/guidelines/modelService/modelService.generate.json +0 -31
- package/guidelines/modelSignal/modelSignal.generate.json +0 -31
- package/guidelines/modelStore/modelStore.generate.json +0 -31
- package/guidelines/modelTemplate/modelTemplate.generate.json +0 -31
- package/guidelines/modelUnit/modelUnit.generate.json +0 -31
- package/guidelines/modelUtil/modelUtil.generate.json +0 -31
- package/guidelines/modelView/modelView.generate.json +0 -31
- package/guidelines/modelZone/modelZone.generate.json +0 -31
- package/guidelines/moduleCodegen/moduleCodegen.generate.json +0 -31
- package/guidelines/moduleCodegen/moduleCodegen.instruction.md +0 -28
- package/guidelines/moduleOverview/moduleOverview.generate.json +0 -31
- package/guidelines/queryRule/queryRule.generate.json +0 -31
- package/guidelines/recipeRule/recipeRule.generate.json +0 -31
- package/guidelines/runtimeRule/runtimeRule.generate.json +0 -25
- package/guidelines/scalarConstant/scalarConstant.generate.json +0 -32
- package/guidelines/scalarDictionary/scalarDictionary.generate.json +0 -32
- package/guidelines/scalarModule/scalarModule.generate.json +0 -31
- package/guidelines/sharedUiUsage/sharedUiUsage.generate.json +0 -31
- package/guidelines/sharedUiUsage/sharedUiUsage.instruction.md +0 -25
- package/guidelines/ssrRule/ssrRule.generate.json +0 -31
- package/guidelines/transportRule/transportRule.generate.json +0 -31
- package/guidelines/utilUiUsage/utilUiUsage.generate.json +0 -31
- package/guidelines/utilUiUsage/utilUiUsage.instruction.md +0 -25
- package/guidelines/workspaceOnboarding/workspaceOnboarding.generate.json +0 -24
- package/guidelines/workspaceRecipes/workspaceRecipes.generate.json +0 -33
- package/index-2hq52jq3.js +0 -465
- package/index-47pj3aee.js +0 -76
- package/index-6wwzs1bc.js +0 -7
- package/index-8pm30m73.js +0 -841
- package/index-kn1h7p1x.js +0 -560
- package/index-meh558jy.js +0 -65
- package/index-rwg2aa4f.js +0 -229
- package/index-w8kmx1b6.js +0 -2176
- package/index-wt7qrtd4.js +0 -1516
- package/templates/__scalar/__model__/__model__.abstract.md +0 -28
- package/templates/module/__model__.abstract.md +0 -28
- package/templates/service/__model__.abstract.md +0 -28
- package/templates/workspaceRoot/patches/react-dom@19.2.7.patch.template +0 -62
- package/workflow.command-nwpcdc8p.js +0 -107
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
script,
|
|
4
|
+
command
|
|
5
|
+
} from "./index-xb7qhxa8.js";
|
|
6
|
+
import"./index-52w0fvh8.js";
|
|
7
|
+
import"./index-n3jk2501.js";
|
|
8
|
+
import {
|
|
9
|
+
Prompter2
|
|
10
|
+
} from "./index-zzvvc845.js";
|
|
11
|
+
|
|
12
|
+
// pkgs/@akanjs/cli/guideline/guideline.script.ts
|
|
13
|
+
import { Logger } from "akanjs/common";
|
|
14
|
+
|
|
15
|
+
class GuidelineScript extends script("guideline") {
|
|
16
|
+
async guideline(action, name = null) {
|
|
17
|
+
if (action === "list") {
|
|
18
|
+
const guidelines = await Prompter2.listGuidelines();
|
|
19
|
+
Logger.rawLog(guidelines.join(`
|
|
20
|
+
`));
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (action === "show") {
|
|
24
|
+
if (!name)
|
|
25
|
+
throw new Error("Guideline name is required. Example: akan guideline show framework");
|
|
26
|
+
Logger.rawLog(await Prompter2.getInstruction(name));
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
throw new Error(`Unknown guideline action: ${action}. Use "list" or "show".`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// pkgs/@akanjs/cli/guideline/guideline.command.ts
|
|
34
|
+
class GuidelineCommand extends command("guideline", [GuidelineScript], ({ public: target }) => ({
|
|
35
|
+
guideline: target({ desc: "List or show Akan AI guideline instructions" }).arg("action", String, { desc: "list or show" }).arg("name", String, { desc: "guideline name for show", nullable: true }).exec(async function(action, name) {
|
|
36
|
+
await this.guidelineScript.guideline(action, name);
|
|
37
|
+
})
|
|
38
|
+
})) {
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
GuidelineCommand
|
|
42
|
+
};
|
|
@@ -15,6 +15,13 @@ for. `Load` scopes, the route, and the live keys complete the context. The React
|
|
|
15
15
|
apps and libs never import it directly (`no-import-external-library`) — everything reaches them through `st.*` and
|
|
16
16
|
`akanjs/ui`.
|
|
17
17
|
|
|
18
|
+
**Mounted is not published: on a CSR stack only the current page is.** The page kept under the current one for a
|
|
19
|
+
swipe back stays mounted and live, and its declarations stay registered, but its tools, resources, guides and
|
|
20
|
+
`st.use` keys are parked until it is current again — the agent sees the screen the user sees, never two. Each page
|
|
21
|
+
container renders `use-agentic`'s `<AgentActivity active>` for this; a parked registration shadows nothing, two
|
|
22
|
+
pages declaring one name never clash, and a registry kept outside the surface reads the same gate through
|
|
23
|
+
`useAgentGate()`, as the store's live keys do.
|
|
24
|
+
|
|
18
25
|
## Mounting The Chat
|
|
19
26
|
- **Mount `<Agent.Chat />` once in a layout.** That is the floating chat, the approval card, and the client-side
|
|
20
27
|
loop. The default runner drives `runAgentTurn`, which the **framework serves on every app** — no lib to mount,
|
|
@@ -45,10 +52,16 @@ apps and libs never import it directly (`no-import-external-library`) — everyt
|
|
|
45
52
|
clear and close. `chrome={false}` drops the header bar whole, for an `inline` chat inside a panel the app
|
|
46
53
|
already titles, and `defaultDraft` opens the composer with text in it without sending it. A panel driven by a
|
|
47
54
|
controlled `open` with **no** `onOpenChange` draws no close button at all rather than an inert one. Then the
|
|
48
|
-
slots: `AgentLauncher`, `AgentBubble`, `AgentComposer`, `AgentApproval`,
|
|
49
|
-
`AgentQuestion`, `AgentQueued`, `AgentMenu`, `AgentMarkdown` and `AgentCode` each replace one part in `_overrides.tsx`, and
|
|
55
|
+
slots: `AgentLauncher`, `AgentSteps`, `AgentBubble`, `AgentComposer`, `AgentApproval`,
|
|
56
|
+
`AgentQuestion`, `AgentToolCard`, `AgentQueued`, `AgentMenu`, `AgentMarkdown` and `AgentCode` each replace one part in `_overrides.tsx`, and
|
|
50
57
|
`akanjs/ui` exports every default beside them (`DefaultBubble`, `DefaultComposer`, …) so a skin composes the
|
|
51
|
-
one it is replacing. `
|
|
58
|
+
one it is replacing. **`AgentSteps` is one agent turn** — the messages between the user message that opened it
|
|
59
|
+
and the next one, with `isRunning` saying whether more are still coming — which is the grain a chat needs to
|
|
60
|
+
fold a turn's steps into a `details` and stand its answer outside them. It is the one boundary a per-message
|
|
61
|
+
slot cannot see, since neither message on either side of it knows it is at an edge. The default draws the turn's
|
|
62
|
+
messages flat into a Fragment, so a chat that binds nothing renders exactly what it did before the slot existed. The attachment row is exported on its own as `AgentAttachments`, because a replaced
|
|
63
|
+
`AgentBubble` that redraws it by hand forks the rule for which carrier is shown how — and then keeps whatever
|
|
64
|
+
that rule was on the day it was copied. `AgentCode` is where a highlighter binds — the fence's language reaches it — and a
|
|
52
65
|
replacement for `AgentBubble` carries its own `memo`, since the transcript re-renders on every delta. Only then
|
|
53
66
|
`AgentChat`, which replaces the panel whole: it also replaces the slash commands, the compaction notice and the
|
|
54
67
|
approval gate, so reach for it when the *layout* differs, not when the look does.
|
|
@@ -70,24 +83,41 @@ apps and libs never import it directly (`no-import-external-library`) — everyt
|
|
|
70
83
|
- **The LLM is configured in `option.ts`, never through the environment.** `option.setLlm({ apiKey, model, host })`
|
|
71
84
|
— or `setLlm((options) => …)` to read the key out of the app's own env object, which is where a secret belongs —
|
|
72
85
|
fills whichever adaptor holds `LlmAdaptorRole`, reaching it as the `llmOption` use. The settings are the role's
|
|
73
|
-
rather than one provider's, so they survive a swap.
|
|
74
|
-
`https://api.
|
|
75
|
-
providers the way middleware is applied:
|
|
76
|
-
write its own — an `adapt()` class in a
|
|
77
|
-
ignoring `onDelta` still answers whole —
|
|
78
|
-
|
|
79
|
-
`
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
+
rather than one provider's, so they survive a swap. **`OpenaiLlm` is the built-in default**, pointed at
|
|
87
|
+
`https://api.openai.com/v1`; with no `apiKey` or no `model` the app still boots and the chat answers
|
|
88
|
+
`llmUnavailable`. Swap providers the way middleware is applied:
|
|
89
|
+
`option.applyAdaptor(LlmAdaptorRole, AnthropicLlm)`. An app may still write its own — an `adapt()` class in a
|
|
90
|
+
`srvkit/` implementing `LlmAdaptor.chat(request, onDelta?)`, where ignoring `onDelta` still answers whole — and
|
|
91
|
+
whatever settings it needs beyond `LlmOption` travel through the same `setLlm`, read back with
|
|
92
|
+
`use<MyLlmOption>()` from an interface extending it.
|
|
93
|
+
- **Two adaptors ship, one per wire — a vendor is a host and a model name, not a protocol.** `OpenaiLlm` is the
|
|
94
|
+
chat-completions dialect (`OpenaiDialect`) pointed at whatever `host` names, so OpenAI, DeepSeek, Groq,
|
|
95
|
+
Together, OpenRouter, Ollama and a self-hosted vLLM are all one class and one `option.setLlm({ host, model })`.
|
|
96
|
+
`AnthropicLlm` is the Messages API and declares `{ image: true, document: true }`; it is its own file rather
|
|
97
|
+
than a branch, because the system prompt is a field and not a message, tool calls and results are content
|
|
98
|
+
blocks, the results ride in a *user* turn, roles must alternate — so two wire turns that map to one role are
|
|
99
|
+
merged — and `max_tokens` is required. **Both require `model`**: a default would age into a 404, and worse, it
|
|
100
|
+
would decide the vision claim for the app.
|
|
101
|
+
- **`OpenaiLlm` claims vision for its default host and for nothing else.** OpenAI's own endpoint takes image
|
|
102
|
+
parts, so that is what it answers with no `host` set. A `host` the app named is a gateway the class knows
|
|
103
|
+
nothing about, and it stays text-only until `option.setLlm({ accepts })` says otherwise — handing bytes to a
|
|
104
|
+
model that cannot decode them kills the whole turn on a 400, where text-only degrades them to a note the model
|
|
105
|
+
can repeat back.
|
|
106
|
+
- **A refusal is `agent.error.llmRequestFailed`, and it names the host** — unless the prompt did not fit. The
|
|
107
|
+
provider's own sentence rides in `reason` and the hostname in `provider`. `LlmOverflow.refusal(host, status,
|
|
108
|
+
reason)` builds it, and reads the one refusal a chat can undo — a prompt past the window, recognized from each
|
|
109
|
+
provider's own sentence — as `agent.error.contextOverflow` with the `limit` it named, which the relay flags so
|
|
110
|
+
the chat compacts and asks again. An adaptor an app wrote throws through the same function, so its refusals
|
|
111
|
+
translate and recover the way the shipped ones do without a key in the framework's dictionary it cannot add.
|
|
86
112
|
- **`accepts` is answered per model, through `option.setLlm({ accepts })`.** An adaptor answers for an API and one
|
|
87
113
|
API serves models that differ, so the override rides beside the `model` it is a fact about. It is not a table
|
|
88
114
|
the framework keeps: a table is a claim about models that ship after it, and getting this wrong is the worst
|
|
89
115
|
failure available — a provider handed bytes it cannot decode either refuses the turn or accepts it having seen
|
|
90
116
|
nothing, and the model then answers confidently about a file it never read.
|
|
117
|
+
- **`contextWindow` is declared the same way: `option.setLlm({ contextWindow })`.** Every turn relays it with the
|
|
118
|
+
answer ceiling the adaptor actually sends (`LlmAdaptor.limits` — `AnthropicLlm` always sends one, `OpenaiLlm`
|
|
119
|
+
none), and the chat guards its window with it. It is not a table either; a model id is retired or renamed long
|
|
120
|
+
before a table notices.
|
|
91
121
|
- **An adaptor answers `null` for "not configured" and *throws* for a refusal it can explain.** The two are
|
|
92
122
|
different things to be told: collapsing both into `null`, the way the adapter convention otherwise reads, left a
|
|
93
123
|
user reading `llmUnavailable` — "no model is configured" — about a conversation that had merely outgrown the
|
|
@@ -110,8 +140,9 @@ apps and libs never import it directly (`no-import-external-library`) — everyt
|
|
|
110
140
|
arrives as an image. `accepts.document` is one boolean over every non-image type, so an adaptor whose API has a
|
|
111
141
|
block for only some of them — Anthropic's `document` is PDF and nothing else — names the rest in the text rather
|
|
112
142
|
than dropping them, which is the wire's own rule applied at the one layer that knows which blocks exist. Persisting keeps each
|
|
113
|
-
attachment's name and drops its content: web storage is a few megabytes, one
|
|
114
|
-
a save that fails is silent — so keeping the bytes would quietly stop keeping
|
|
143
|
+
attachment's name, type, address and `ref` and drops only its content: web storage is a few megabytes, one
|
|
144
|
+
screenshot fills a chunk of it, and a save that fails is silent — so keeping the bytes would quietly stop keeping
|
|
145
|
+
the transcript, while an id is the handle a restored conversation has left to find the file with.
|
|
115
146
|
**The ceilings are the message's, not the file's**: 4 MB per file, 8 MB and five files per message, and the same
|
|
116
147
|
file twice is refused by name. The bytes ride inside one turn's JSON, so what a provider refuses is the sum —
|
|
117
148
|
and a request that cannot be sent is one the user has to empty the composer to escape, which is why the refusal
|
|
@@ -121,11 +152,19 @@ apps and libs never import it directly (`no-import-external-library`) — everyt
|
|
|
121
152
|
reader produced**, not on the file that was picked: a reader that uploads and answers a `url` has already paid
|
|
122
153
|
what the ceiling exists for, so refusing its 6 MB photo would refuse it for a cost it does not incur. Only the
|
|
123
154
|
built-in path checks the source size, and there the file itself is the carrier.
|
|
124
|
-
- **
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
because the
|
|
155
|
+
- **An app may also build attachments itself and hand them to `session.send([{ role: "user", text, attachments }])`**,
|
|
156
|
+
which is why `MessageAttachment` is exported from `akanjs/ui` — the composer's path is typed by the `AttachReader`
|
|
157
|
+
callback, that one is not, and an object assembled with no nameable type is the one that gets a field wrong.
|
|
158
|
+
Nothing downstream trusts the result: an attachment whose `mimeType` is not a string is noted like any other
|
|
159
|
+
unreadable one, and its chip renders its name with no preview, because the host wrote the object and the declared
|
|
160
|
+
type is a claim rather than a check. A field that arrives wrong costs that attachment, never the turn.
|
|
161
|
+
- **A `url` carrier is an address the *provider* fetches, and bytes beside it win.** A reader that uploads answers
|
|
162
|
+
`{ url }` when its storage is publicly reachable, and `{ data }` — or both — when it is not: an attachment
|
|
163
|
+
carrying both is read from its bytes and displayed from its address, so the chip draws a thumbnail and the model
|
|
164
|
+
still gets the picture. That precedence exists because the other order fails the one way nothing reports: the
|
|
165
|
+
default storage backend serves a path only the app can resolve, the adaptor would hand it over as written, and
|
|
166
|
+
the model answers about a picture it never saw. Send a provider-reachable URL **alone** — paired with bytes it
|
|
167
|
+
costs the provider hop whatever the bytes weigh, for a fetch the provider would have done itself.
|
|
129
168
|
- **An image type the provider has no block for is refused at the adaptor, not upstream.** `accepts.image` is one
|
|
130
169
|
boolean, so `AgentService.readable` passes every `image/*` through, and the built-in composer reader base64s
|
|
131
170
|
every `image/*` as well — an `AttachReader` answering `null` means "not mine" and falls through to it, so an app
|
|
@@ -149,10 +188,56 @@ apps and libs never import it directly (`no-import-external-library`) — everyt
|
|
|
149
188
|
there: a voice user who is never told about the card is a conversation that simply ends.
|
|
150
189
|
The contract is a subscription rather than `listen(): Promise<string>` on purpose: a promise fits push-to-talk
|
|
151
190
|
and nothing else, so hands-free could then only arrive as a breaking change. `useSpeech` in a util lib's
|
|
152
|
-
`webkit/` is the engine — the browser's own recognition and synthesis
|
|
153
|
-
|
|
154
|
-
|
|
191
|
+
`webkit/` is the engine — the browser's own recognition and synthesis. An app's WebView **has neither on
|
|
192
|
+
Android or iOS** and `@akanjs/native` ships no speech plugin yet, so a `speech.plugin.ts` declares only the
|
|
193
|
+
permission and its usage texts. An engine answering `available()` false renders no microphone at all,
|
|
155
194
|
the same rule as publishing no tool for a control the screen does not draw.
|
|
195
|
+
- **Data the user points at rides the message too, as `references` — and its value is a snapshot.** A file is
|
|
196
|
+
something they handed over; a reference is something they pointed at while asking, so it belongs in the same
|
|
197
|
+
place and for the same reason. Screen context does not do this job: `ContextBlock`s are rebuilt from the screen
|
|
198
|
+
every turn, so what was named three turns ago is simply not in the conversation any more. A `MessageReference`
|
|
199
|
+
carries the host's own `refName`, the id, a label, an optional dotted `path` into the document, and the `value`
|
|
200
|
+
those resolved to. **The value is never re-read on a later turn**, which is the point: re-reading rewrites what
|
|
201
|
+
the person was looking at when they spoke, and the usual next thing the agent does is edit the very field it was
|
|
202
|
+
pointed at — leaving a live reference showing the result with no record of what it was changed from.
|
|
203
|
+
`refName`/`refId`/`path` travel so a tool can read the current value when the answer needs it, and
|
|
204
|
+
`AgentService.referenced` folds the whole lot into the message text in one place, so every provider carries a
|
|
205
|
+
reference without either adaptor knowing the word. **The value is masked on the way in and nowhere else**: masking
|
|
206
|
+
needs the model class, which no wire carries, so the model a host names when it stages the reference is the whole
|
|
207
|
+
of the decision about what leaves the browser — name the class that actually holds the field, because a `Light`
|
|
208
|
+
one usually does not. **The ceiling is 20,000 characters per reference**, applied as it is staged and again on
|
|
209
|
+
the server; a reference is bulkier than a tool result and outlives one, riding every later turn and being the last
|
|
210
|
+
thing compaction folds. Persisting keeps the pointer and drops the value with a note saying so, which is a better
|
|
211
|
+
restored state than an attachment can offer — the pointer is still live, so the answer is to read it again.
|
|
212
|
+
Staging lives on the **session** (`stage` / `staged` / `unstage(key)` / `clearStaged()`), not on the composer where
|
|
213
|
+
staged files live, because a reference comes from whichever component drew the data rather than from the paperclip;
|
|
214
|
+
`unstage` is keyed on `refName/refId#path` because what orders a message's references is its text, not that list.
|
|
215
|
+
- **Two ways to point at data, and which one depends on who knows the value.** `<Agent.Chat reference={[…]} />`
|
|
216
|
+
takes one `ReferenceSource` per kind of document — `refName`, a `type`, the app's own `search`, and a `resolve` —
|
|
217
|
+
and the composer's `@` menu offers whole documents from them; the token is written the moment a row is picked and
|
|
218
|
+
the value is staged when `resolve` lands, so a slow fetch never freezes the menu and one that fails leaves a
|
|
219
|
+
pointer that reads as *go and read it*. For a field *inside* a document, the component drawing it calls
|
|
220
|
+
`useAgentReference()` — it already holds the value, so there is no round trip, and it is the only thing that
|
|
221
|
+
knows a rich-text field stored as `field(Any)` reads as a paragraph rather than as the editor document it is. The
|
|
222
|
+
hook no-ops with a warning outside a session, the same call `AgentValue.publishable` makes: a card carrying a
|
|
223
|
+
reference button must not cost a route its render.
|
|
224
|
+
- **The token in the draft is what carries a reference, and the chip only draws it.** Deleting
|
|
225
|
+
`@[label](mention:refName/id#path)` by hand drops the reference exactly as removing the chip does — removing the
|
|
226
|
+
chip removes the token — so the two can never disagree, and nothing re-derives a value from text somebody edited.
|
|
227
|
+
A token pasted out of an earlier message travels as a pointer with a note, which is the same shape a restored
|
|
228
|
+
conversation produces. Staged references are the **session's**, not the composer's, because `useAgentReference`
|
|
229
|
+
is called from components the composer cannot see; writing the token is the composer's half, and `refer` warns
|
|
230
|
+
rather than staging silently when no chat is mounted on that session — the case where a card sits outside the
|
|
231
|
+
`<Agent.Zone>` its chat is inside.
|
|
232
|
+
- **The composer draws a pointer as the name it points at, never as the token.** Where `reference` sources are
|
|
233
|
+
declared the input is a Lexical editor rather than a textarea, and each pointer is one atomic node — a backspace
|
|
234
|
+
takes the whole thing rather than a character of a label that would then name nothing. Nothing above it changes:
|
|
235
|
+
the node's text content *is* the `@[…](mention:…)` token, so the draft string the chat reads, the `@` query, the
|
|
236
|
+
chips, the wire and the server's framing all see what they always saw, and every offset the chat hands over is
|
|
237
|
+
an offset into that string. It is its own chunk behind the chat's, fetched only where a source was declared, and
|
|
238
|
+
`mentions={false}` keeps the plain textarea — for an app that overrides `AgentComposer`, or one that would
|
|
239
|
+
rather see the tokens it is sending. An override that draws its own textarea keeps working: it fills the
|
|
240
|
+
`inputRef` it is handed, and the chat reads the caret off that when no editor filled `handleRef`.
|
|
156
241
|
- **`attach` and `voice` both carry functions, so a server layout cannot pass either.** A closure does not cross
|
|
157
242
|
the RSC boundary — `non-scalar-props-restricted` says so on `page/**` — so an app that wants either mounts the
|
|
158
243
|
chat from a small client component in the app's own `ui/` that calls the hook.
|
|
@@ -224,6 +309,14 @@ apps and libs never import it directly (`no-import-external-library`) — everyt
|
|
|
224
309
|
`data-akan-action` like a store setter does. A `remove*` name defaults to a confirm gate. Reach a store action
|
|
225
310
|
from the body — `.exec((id) => st.do.removeX(id))` — which is how an agent gets CRUD; `st.do` on its own
|
|
226
311
|
reaches nobody.
|
|
312
|
+
- **`.card()` is the other way the chain ends, for an answer that is the user's to give.** Where `.exec()` runs a
|
|
313
|
+
function, `.card(({ submit, cancel }, ...args) => <Form …/>)` parks the call in the chat and renders the app's own
|
|
314
|
+
component there; what `submit` is handed is what the model reads back, and `cancel` is the refusal it reads
|
|
315
|
+
instead. A name and a phone number, a date somebody has to look up, a signature — a model that fills those in
|
|
316
|
+
has answered its own question, and every other shape of "ask the user" is `askUser`. The declared arguments are
|
|
317
|
+
checked **before** the card is parked, so a bad one reaches the model as a refusal rather than throwing inside
|
|
318
|
+
the render; `confirm` is not read at all, because the card in front of the user is already the asking. The frame
|
|
319
|
+
draws its own way out even when the card does not, and the turn is never parked on something with no exit.
|
|
227
320
|
- **The second argument is how the call behaves, never what it is.** `{ settle, confirm, guard }`:
|
|
228
321
|
`settle: false` marks a read that returns what is already there and skips the wait; every other tool is waited
|
|
229
322
|
out before its effect on the screen is reported, because a write may still be landing when `exec` resolves. A
|
|
@@ -459,18 +552,29 @@ apps and libs never import it directly (`no-import-external-library`) — everyt
|
|
|
459
552
|
- **A long conversation summarizes itself, because nothing else is keeping it inside the model's window.** The
|
|
460
553
|
loop runs in the browser and the relay holds no session, so an uncompacted chat grows until the provider
|
|
461
554
|
refuses the whole request — a refusal, never a shorter answer, which is why compaction runs *before* the turn
|
|
462
|
-
that would have overflowed
|
|
463
|
-
characters to a token, over the JSON the turn posts
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
555
|
+
that would have overflowed. **Two triggers, each before every assistant turn.** `compact.at` is a ceiling on
|
|
556
|
+
cost: past that many estimated transcript tokens (four characters to a token, over the JSON the turn posts —
|
|
557
|
+
except an inlined picture, counted at the ~1,600 tokens a provider bills for its pixels rather than its base64;
|
|
558
|
+
24k by default) the history compacts, because the relay resends the whole transcript every turn and the app
|
|
559
|
+
pays for each one. The **window guard** compacts once the prompt nears the window the server reports —
|
|
560
|
+
`window − answer ceiling (8,192 when unreported) − compact.buffer (13,000, the margin Claude Code leaves)` —
|
|
561
|
+
measured by the provider's own count of the last turn (`done.usage`, kept on that assistant message) plus the
|
|
562
|
+
four-character estimate for what arrived since, so a Korean transcript the character rule reads as small is
|
|
563
|
+
still caught. The window comes from `option.setLlm({ contextWindow })` or from the first refusal that names it;
|
|
564
|
+
with neither, only the ceiling runs. **A refusal for length is answered once**: a relay flags it `overflow` on
|
|
565
|
+
the wire, and the session compacts and sends the same turn again, and a second refusal in the same send fails
|
|
566
|
+
with `agent.error.contextOverflow`. Either way the history above the last `keep` messages
|
|
567
|
+
becomes one message standing in for it, flagged `summary` on the wire — `<Agent.Chat compact={{ at, keep, buffer }} />`
|
|
568
|
+
tunes it, `{ at: Infinity }` leaves only the window guard, `{ at: 0 }` turns off the ceiling, the guard and the recovery alike, and `/compact` does
|
|
569
|
+
the same on demand keeping nothing. The header draws the estimate against whichever trigger is nearer.
|
|
467
570
|
**The cut never lands on a `tool` message**: the kept half may not open with a result whose call was summarized
|
|
468
571
|
away, a shape every provider dialect rejects. A user message is preferred where the tail holds one — everything
|
|
469
572
|
above it is settled — but one assistant turn that ran ten tools has none, and that is the transcript that
|
|
470
573
|
outgrows the window, so a cut there opens on the assistant message instead. The summarizing
|
|
471
574
|
turn carries no tools and no screen context — it summarizes the conversation, it does not act on it — and it is
|
|
472
575
|
fed a *bounded* digest rather than the transcript itself, since the transcript being summarized is the one that
|
|
473
|
-
no longer fits.
|
|
576
|
+
no longer fits. The previous summary is the exception: it rides the digest whole, under its own label and outside
|
|
577
|
+
the bound, because it is the only record of what was compacted before it. A summary that cannot be produced leaves the transcript alone, the turn goes out as it would
|
|
474
578
|
have, and the next one asks again — a summarizer that was momentarily unreachable says nothing about whether
|
|
475
579
|
this transcript can shrink. One that *landed* and shrank nothing does, so that one is not retried until another
|
|
476
580
|
threshold's worth has been added. On the
|
|
@@ -622,4 +726,76 @@ apps and libs never import it directly (`no-import-external-library`) — everyt
|
|
|
622
726
|
is among them. The loop parks on the question exactly as it parks on an approval, a dismissal is the tool's
|
|
623
727
|
error result rather than a silent empty answer, and the settled exchange renders as question-and-answer instead
|
|
624
728
|
of a tool row. **Never re-implement it per screen** — a `st.tool("askAboutX")` that opens a modal is the same
|
|
625
|
-
thing with a worse transcript — and a hook tool named `askUser` shadows it like any other built-in.
|
|
729
|
+
thing with a worse transcript — and a hook tool named `askUser` shadows it like any other built-in. The line
|
|
730
|
+
between it and a `.card()` tool is what the answer *is*: a sentence or a pick off a list is `askUser` and belongs
|
|
731
|
+
to the conversation, while a shape the model must not invent — fields, a form, a signature — is a card the screen
|
|
732
|
+
declares, because only the screen knows what filling it in looks like.
|
|
733
|
+
|
|
734
|
+
## What The Page Draws
|
|
735
|
+
- **The page shows the agent's work, not just the transcript.** A chat panel is closed as often as it is open, and
|
|
736
|
+
a form that fills itself or a tab that switches on its own is a change the user watches happen with nothing
|
|
737
|
+
anywhere attributing it. So **the control a call was published from is ringed** where it stands, scrolled to
|
|
738
|
+
first when it is off screen, and **a pointer travels to it and presses it** — both on by default, and both
|
|
739
|
+
driven from the tool call itself rather than from a store action, which cannot tell the agent's write from the
|
|
740
|
+
user's.
|
|
741
|
+
- **It costs an app nothing, for the same reason `data-akan-action` does.** `onChange={st.do.setTitleOnTask}` by
|
|
742
|
+
reference is what annotates the control, and the annotation is what makes it findable — so the fields and verbs
|
|
743
|
+
that matter light up with no code. An inline arrow publishes no tool, carries no annotation, and therefore
|
|
744
|
+
draws nothing: one wrapper silently costs three things at once.
|
|
745
|
+
- **For a control the framework did not render, spread `agentAttrs`** from `akanjs/ui`:
|
|
746
|
+
`<button {...agentAttrs(run)} onClick={run}>`, where `run` is what `st.tool(…).exec(…)` returned. It reads the
|
|
747
|
+
name off the callable, so there is nothing to keep in sync and no `ref` to thread — and it earns the same E2E
|
|
748
|
+
selector and accessibility name an `akanjs/ui` control has. Never hand-write `data-akan-*`.
|
|
749
|
+
- **A control that shares its handler with its siblings takes a key**: `agentAttrs(switchTab, menu)`, in the same
|
|
750
|
+
vocabulary the call's argument uses. One tool serves a whole tab strip or a whole list, so without it every
|
|
751
|
+
namesake is interchangeable in the DOM and the page can say *what* the agent did but never *where* — which the
|
|
752
|
+
no-guessing rule then turns into drawing nothing. `Tab.Menu` passes its `menu` key; do the same for a row verb
|
|
753
|
+
whose id the call names.
|
|
754
|
+
- **Almost nothing is waited on.** The call starts the moment the effect is handed its event; a ring that lands a
|
|
755
|
+
frame later costs the turn nothing, and an animation that held a call would make the agent slower for a
|
|
756
|
+
decoration. A turn past four scrolls stops scrolling and keeps ringing — eight scrolls across a page is motion
|
|
757
|
+
sickness rather than attribution. **The one exception is `navigate`**, whose press has to land before the router
|
|
758
|
+
replaces the tree the link is in; it is capped at 600ms and the call goes either way.
|
|
759
|
+
- **What it refuses to draw is the point.** A name several rows answer to rings nothing rather than guessing a row,
|
|
760
|
+
a call an approval or a guard turned back is never drawn at all, a tool no control carries draws nothing, and a
|
|
761
|
+
backgrounded tab draws nothing. A ring on the wrong element is worse than no ring: it is the screen telling the
|
|
762
|
+
user something untrue about what just happened. **A control the screen is not actually showing is not pointed at
|
|
763
|
+
either, and the pointer goes rather than travelling to it**: `checkVisibility` answers about an element alone, so
|
|
764
|
+
one under a modal's backdrop, inside a drawer that has slid off, or faded to nothing all pass it while being
|
|
765
|
+
invisible, and a pointer sent there lands on a blank patch of overlay. The test is `elementFromPoint` at the
|
|
766
|
+
control's own centre, taken after the reveal has settled. **`navigate` is mostly in that last class** — the router is not
|
|
767
|
+
an element, so it draws nothing. A bar across the top of the page was tried for it and removed: it read as
|
|
768
|
+
chrome the page had grown rather than as the agent doing something, which is the opposite of attribution. What
|
|
769
|
+
it does draw is the **link already on screen that goes where it is going**, when exactly one does and the user
|
|
770
|
+
can already see it: that one is an element, and the pointer presses it before the route moves. Addresses are
|
|
771
|
+
compared as routes (`router.routeOf`), since the locale and base-path segments are on the `<a>` and never on the
|
|
772
|
+
tool argument. An off-screen link is left alone — scrolling to a link and then leaving the page it is on is two
|
|
773
|
+
motions for one act. **Link presence is a drawing condition, never a permission one**: the agent may navigate
|
|
774
|
+
anywhere the user could type, and a zone that must not leave one screen drops `navigate` through `builtins`.
|
|
775
|
+
- **Turn it off with `visual`** on `Agent.Chat` / `Agent.Zone` — `false` for all of it, `{ cursor: false }` or
|
|
776
|
+
`{ reveal: false }` for one effect. The pointer is chrome (`data-agent-ui`, `aria-hidden`,
|
|
777
|
+
`pointer-events: none`), so `readScreen` never reads it back and `highlight` can never aim at it.
|
|
778
|
+
- **`ToolActivity` is the channel underneath**, a `ToolRunner` host option and an `AgentSession.onActivity`, firing
|
|
779
|
+
`start` / `end` around the execution alone. It is deliberately not `progress`: that one fires only for a tool
|
|
780
|
+
that chose to report, and a tool that says nothing about itself is exactly the one whose effect arrives
|
|
781
|
+
unexplained. The `start` may answer a promise, and the call waits for it — the whole of what makes drawing a
|
|
782
|
+
click on a link possible.
|
|
783
|
+
- **`AgentSession.onTurn(running)` is the other half**, and the unit the pointer's life is measured in. A model's
|
|
784
|
+
calls arrive with its own writing between them, seconds each, so a pointer that lived for the length of a *call*
|
|
785
|
+
spent every turn vanishing and coming back. Only the conversation loop reports there — `compact` runs under the
|
|
786
|
+
same internal flag and drives nothing on screen.
|
|
787
|
+
- **The pointer presses on arrival, never on departure** — a press fired as it leaves is a click on whatever it
|
|
788
|
+
was still over. It glides only when the hop is far enough to be worth following (a third of a second to cross
|
|
789
|
+
fifty pixels reads as lag, not motion), and teleports otherwise. It appears at the first control it presses,
|
|
790
|
+
**drifts clear of what it pressed** and waits out the gap between calls there as a spinner — a person clicks and
|
|
791
|
+
takes the hand away, and a spinner left sitting on the button covers the change it just caused — and fades when
|
|
792
|
+
the turn ends; **a turn that
|
|
793
|
+
drove no control draws no pointer at all**, since parking one in a corner for a turn that only answered a
|
|
794
|
+
question claims something that did not happen. While a reveal scrolls, it holds still — as a person's does — and
|
|
795
|
+
carries a chevron pointing the way the view is travelling, because stillness over a sliding page otherwise reads
|
|
796
|
+
as a pointer that has come loose rather than as the one doing the scrolling. The ring answers *where* and the
|
|
797
|
+
pointer answers *who*, which is why they are one default rather than two.
|
|
798
|
+
- **A form patch fans out over the fields it named.** `fill<Model>Form` is published by the form rather than by any
|
|
799
|
+
one control, so it rings one control per field in the arguments — resolved through the same
|
|
800
|
+
`data-akan-state="<model>Form.<field>"` the setter annotates — capped at five. `writeOn<Model>(path, value)`
|
|
801
|
+
draws nothing, for the same reason it carries no annotation: there is no control to put one on.
|