@yaks/session 0.0.0-stage → 0.2.36
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/LICENSE +202 -0
- package/README.md +1392 -2
- package/_dist/admission.d.ts +15 -0
- package/_dist/admission.d.ts.map +1 -0
- package/_dist/announce.d.ts +17 -0
- package/_dist/announce.d.ts.map +1 -0
- package/_dist/answer.d.ts +200 -0
- package/_dist/answer.d.ts.map +1 -0
- package/_dist/append.d.ts +10 -0
- package/_dist/append.d.ts.map +1 -0
- package/_dist/archive.d.ts +6 -0
- package/_dist/archive.d.ts.map +1 -0
- package/_dist/asks.d.ts +11 -0
- package/_dist/asks.d.ts.map +1 -0
- package/_dist/audit.d.ts +15 -0
- package/_dist/audit.d.ts.map +1 -0
- package/_dist/bounce.d.ts +19 -0
- package/_dist/bounce.d.ts.map +1 -0
- package/_dist/bus.d.ts +8 -0
- package/_dist/bus.d.ts.map +1 -0
- package/_dist/cache.d.ts +45 -0
- package/_dist/cache.d.ts.map +1 -0
- package/_dist/child-notice.d.ts +6 -0
- package/_dist/child-notice.d.ts.map +1 -0
- package/_dist/children.d.ts +59 -0
- package/_dist/children.d.ts.map +1 -0
- package/_dist/cli.d.ts +8 -0
- package/_dist/cli.d.ts.map +1 -0
- package/_dist/comp.d.ts +9 -0
- package/_dist/comp.d.ts.map +1 -0
- package/_dist/compact.d.ts +19 -0
- package/_dist/compact.d.ts.map +1 -0
- package/_dist/conversation.d.ts +158 -0
- package/_dist/conversation.d.ts.map +1 -0
- package/_dist/cost.d.ts +13 -0
- package/_dist/cost.d.ts.map +1 -0
- package/_dist/deferred.d.ts +79 -0
- package/_dist/deferred.d.ts.map +1 -0
- package/_dist/ended.d.ts +27 -0
- package/_dist/ended.d.ts.map +1 -0
- package/_dist/files.d.ts +73 -0
- package/_dist/files.d.ts.map +1 -0
- package/_dist/fork.d.ts +23 -0
- package/_dist/fork.d.ts.map +1 -0
- package/_dist/graft.d.ts +33 -0
- package/_dist/graft.d.ts.map +1 -0
- package/_dist/graph.d.ts +14 -0
- package/_dist/graph.d.ts.map +1 -0
- package/_dist/handoff.d.ts +29 -0
- package/_dist/handoff.d.ts.map +1 -0
- package/_dist/imported.d.ts +63 -0
- package/_dist/imported.d.ts.map +1 -0
- package/_dist/intake.d.ts +43 -0
- package/_dist/intake.d.ts.map +1 -0
- package/_dist/joined.d.ts +35 -0
- package/_dist/joined.d.ts.map +1 -0
- package/_dist/lease.d.ts +21 -0
- package/_dist/lease.d.ts.map +1 -0
- package/_dist/lines.d.ts +13 -0
- package/_dist/lines.d.ts.map +1 -0
- package/_dist/mod.d.ts +107 -0
- package/_dist/mod.d.ts.map +1 -0
- package/_dist/naming.d.ts +10 -0
- package/_dist/naming.d.ts.map +1 -0
- package/_dist/native.d.ts +13 -0
- package/_dist/native.d.ts.map +1 -0
- package/_dist/parts.d.ts +145 -0
- package/_dist/parts.d.ts.map +1 -0
- package/_dist/plugin.d.ts +33 -0
- package/_dist/plugin.d.ts.map +1 -0
- package/_dist/project.d.ts +67 -0
- package/_dist/project.d.ts.map +1 -0
- package/_dist/prose.d.ts +7 -0
- package/_dist/prose.d.ts.map +1 -0
- package/_dist/providers.d.ts +36 -0
- package/_dist/providers.d.ts.map +1 -0
- package/_dist/reach.d.ts +39 -0
- package/_dist/reach.d.ts.map +1 -0
- package/_dist/react.d.ts +236 -0
- package/_dist/react.d.ts.map +1 -0
- package/_dist/readers.d.ts +221 -0
- package/_dist/readers.d.ts.map +1 -0
- package/_dist/reap.d.ts +21 -0
- package/_dist/reap.d.ts.map +1 -0
- package/_dist/recall.d.ts +32 -0
- package/_dist/recall.d.ts.map +1 -0
- package/_dist/routes.d.ts +15 -0
- package/_dist/routes.d.ts.map +1 -0
- package/_dist/run.d.ts +81 -0
- package/_dist/run.d.ts.map +1 -0
- package/_dist/service.d.ts +131 -0
- package/_dist/service.d.ts.map +1 -0
- package/_dist/source.d.ts +9 -0
- package/_dist/source.d.ts.map +1 -0
- package/_dist/start.d.ts +29 -0
- package/_dist/start.d.ts.map +1 -0
- package/_dist/state.d.ts +75 -0
- package/_dist/state.d.ts.map +1 -0
- package/_dist/status.d.ts +38 -0
- package/_dist/status.d.ts.map +1 -0
- package/_dist/tail.d.ts +121 -0
- package/_dist/tail.d.ts.map +1 -0
- package/_dist/timing.d.ts +9 -0
- package/_dist/timing.d.ts.map +1 -0
- package/_dist/told.d.ts +17 -0
- package/_dist/told.d.ts.map +1 -0
- package/_dist/tools.d.ts +41 -0
- package/_dist/tools.d.ts.map +1 -0
- package/_dist/transcript.d.ts +5 -0
- package/_dist/transcript.d.ts.map +1 -0
- package/_dist/turn.d.ts +49 -0
- package/_dist/turn.d.ts.map +1 -0
- package/_dist/unknown.d.ts +6 -0
- package/_dist/unknown.d.ts.map +1 -0
- package/_dist/views.d.ts +9 -0
- package/_dist/views.d.ts.map +1 -0
- package/_dist/vocab.d.ts +9 -0
- package/_dist/vocab.d.ts.map +1 -0
- package/_dist/wait.d.ts +15 -0
- package/_dist/wait.d.ts.map +1 -0
- package/_dist/wake.d.ts +116 -0
- package/_dist/wake.d.ts.map +1 -0
- package/_dist/watch.d.ts +52 -0
- package/_dist/watch.d.ts.map +1 -0
- package/_dist/who.d.ts +84 -0
- package/_dist/who.d.ts.map +1 -0
- package/_dist/window.d.ts +43 -0
- package/_dist/window.d.ts.map +1 -0
- package/admission.js +137 -0
- package/admission.js.map +1 -0
- package/admission.ts +164 -0
- package/announce.js +123 -0
- package/announce.js.map +1 -0
- package/announce.ts +126 -0
- package/answer.js +372 -0
- package/answer.js.map +1 -0
- package/answer.ts +426 -0
- package/append.js +125 -0
- package/append.js.map +1 -0
- package/append.ts +205 -0
- package/archive.js +62 -0
- package/archive.js.map +1 -0
- package/archive.ts +62 -0
- package/asks.js +80 -0
- package/asks.js.map +1 -0
- package/asks.ts +106 -0
- package/attempt.js +46 -0
- package/attempt.js.map +1 -0
- package/attempt.ts +60 -0
- package/audit.js +57 -0
- package/audit.js.map +1 -0
- package/audit.ts +65 -0
- package/bounce.js +29 -0
- package/bounce.js.map +1 -0
- package/bounce.ts +34 -0
- package/bus.js +568 -0
- package/bus.js.map +1 -0
- package/bus.ts +683 -0
- package/cache.js +169 -0
- package/cache.js.map +1 -0
- package/cache.ts +230 -0
- package/child-notice.js +128 -0
- package/child-notice.js.map +1 -0
- package/child-notice.ts +136 -0
- package/children.js +937 -0
- package/children.js.map +1 -0
- package/children.ts +925 -0
- package/claude-control.js +8 -0
- package/claude-control.js.map +1 -0
- package/claude-control.ts +12 -0
- package/cli.js +23 -0
- package/cli.js.map +1 -0
- package/cli.ts +28 -0
- package/comp.js +76 -0
- package/comp.js.map +1 -0
- package/comp.ts +78 -0
- package/compact.js +157 -0
- package/compact.js.map +1 -0
- package/compact.ts +209 -0
- package/compact_ask.js +280 -0
- package/compact_ask.js.map +1 -0
- package/compact_ask.ts +199 -0
- package/continue.js +131 -0
- package/continue.js.map +1 -0
- package/continue.ts +143 -0
- package/conversation.js +337 -0
- package/conversation.js.map +1 -0
- package/conversation.ts +593 -0
- package/cost.js +111 -0
- package/cost.js.map +1 -0
- package/cost.ts +93 -0
- package/deferred.js +207 -0
- package/deferred.js.map +1 -0
- package/deferred.ts +219 -0
- package/deno.json +1 -0
- package/dependencies.js +114 -0
- package/dependencies.js.map +1 -0
- package/dependencies.ts +110 -0
- package/draining.js +20 -0
- package/draining.js.map +1 -0
- package/draining.ts +26 -0
- package/ended.js +210 -0
- package/ended.js.map +1 -0
- package/ended.ts +225 -0
- package/files.js +285 -0
- package/files.js.map +1 -0
- package/files.ts +318 -0
- package/fork.js +96 -0
- package/fork.js.map +1 -0
- package/fork.ts +124 -0
- package/graft.js +97 -0
- package/graft.js.map +1 -0
- package/graft.ts +88 -0
- package/graph.js +49 -0
- package/graph.js.map +1 -0
- package/graph.ts +61 -0
- package/handoff.js +111 -0
- package/handoff.js.map +1 -0
- package/handoff.ts +147 -0
- package/help.js +432 -0
- package/help.js.map +1 -0
- package/help.ts +431 -0
- package/hooks.js +253 -0
- package/hooks.js.map +1 -0
- package/hooks.ts +333 -0
- package/imported.js +259 -0
- package/imported.js.map +1 -0
- package/imported.ts +201 -0
- package/inspect.js +353 -0
- package/inspect.js.map +1 -0
- package/inspect.ts +378 -0
- package/intake.js +115 -0
- package/intake.js.map +1 -0
- package/intake.ts +124 -0
- package/joined.js +67 -0
- package/joined.js.map +1 -0
- package/joined.ts +69 -0
- package/lease.js +146 -0
- package/lease.js.map +1 -0
- package/lease.ts +151 -0
- package/lifecycle.js +49 -0
- package/lifecycle.js.map +1 -0
- package/lifecycle.ts +46 -0
- package/lines.js +171 -0
- package/lines.js.map +1 -0
- package/lines.ts +177 -0
- package/listen.js +604 -0
- package/listen.js.map +1 -0
- package/listen.ts +976 -0
- package/log.js +78 -0
- package/log.js.map +1 -0
- package/log.ts +88 -0
- package/mod.js +107 -0
- package/mod.js.map +1 -0
- package/mod.ts +113 -0
- package/name.js +51 -0
- package/name.js.map +1 -0
- package/name.ts +84 -0
- package/naming.js +96 -0
- package/naming.js.map +1 -0
- package/naming.ts +102 -0
- package/native.js +17 -0
- package/native.js.map +1 -0
- package/native.ts +17 -0
- package/package.json +133 -4
- package/parts.js +334 -0
- package/parts.js.map +1 -0
- package/parts.ts +383 -0
- package/plugin.js +77 -0
- package/plugin.js.map +1 -0
- package/plugin.ts +98 -0
- package/project.js +354 -0
- package/project.js.map +1 -0
- package/project.ts +407 -0
- package/prompt.js +57 -0
- package/prompt.js.map +1 -0
- package/prompt.ts +92 -0
- package/prose.js +43 -0
- package/prose.js.map +1 -0
- package/prose.ts +63 -0
- package/providers.js +279 -0
- package/providers.js.map +1 -0
- package/providers.ts +306 -0
- package/pruning.js +80 -0
- package/pruning.js.map +1 -0
- package/pruning.ts +147 -0
- package/reach.js +923 -0
- package/reach.js.map +1 -0
- package/reach.ts +1107 -0
- package/react.js +2259 -0
- package/react.js.map +1 -0
- package/react.ts +2864 -0
- package/readers.js +956 -0
- package/readers.js.map +1 -0
- package/readers.ts +1017 -0
- package/reap.js +60 -0
- package/reap.js.map +1 -0
- package/reap.ts +65 -0
- package/recall.js +67 -0
- package/recall.js.map +1 -0
- package/recall.ts +114 -0
- package/reopen.js +45 -0
- package/reopen.js.map +1 -0
- package/reopen.ts +44 -0
- package/result-entry.js +32 -0
- package/result-entry.js.map +1 -0
- package/result-entry.ts +34 -0
- package/resume.js +266 -0
- package/resume.js.map +1 -0
- package/resume.ts +283 -0
- package/routes.js +129 -0
- package/routes.js.map +1 -0
- package/routes.ts +147 -0
- package/routine.js +179 -0
- package/routine.js.map +1 -0
- package/routine.ts +191 -0
- package/run.js +932 -0
- package/run.js.map +1 -0
- package/run.ts +999 -0
- package/service.js +806 -0
- package/service.js.map +1 -0
- package/service.ts +911 -0
- package/source.js +26 -0
- package/source.js.map +1 -0
- package/source.ts +40 -0
- package/start.js +197 -0
- package/start.js.map +1 -0
- package/start.ts +214 -0
- package/state.js +247 -0
- package/state.js.map +1 -0
- package/state.ts +404 -0
- package/status.js +1222 -0
- package/status.js.map +1 -0
- package/status.ts +1555 -0
- package/status_bench.ts +50 -0
- package/statusline.js +187 -0
- package/statusline.js.map +1 -0
- package/statusline.ts +232 -0
- package/tail.js +748 -0
- package/tail.js.map +1 -0
- package/tail.ts +815 -0
- package/talk.js +58 -0
- package/talk.js.map +1 -0
- package/talk.ts +51 -0
- package/task-context.js +41 -0
- package/task-context.js.map +1 -0
- package/task-context.ts +53 -0
- package/texted.js +65 -0
- package/texted.js.map +1 -0
- package/texted.ts +65 -0
- package/timing.js +37 -0
- package/timing.js.map +1 -0
- package/timing.ts +52 -0
- package/told.js +56 -0
- package/told.js.map +1 -0
- package/told.ts +54 -0
- package/tools.js +595 -0
- package/tools.js.map +1 -0
- package/tools.ts +633 -0
- package/transcript.js +34 -0
- package/transcript.js.map +1 -0
- package/transcript.ts +41 -0
- package/turn.js +47 -0
- package/turn.js.map +1 -0
- package/turn.ts +68 -0
- package/unknown.js +8 -0
- package/unknown.js.map +1 -0
- package/unknown.ts +9 -0
- package/views.js +15 -0
- package/views.js.map +1 -0
- package/views.ts +21 -0
- package/vocab.js +24 -0
- package/vocab.js.map +1 -0
- package/vocab.json +1573 -0
- package/vocab.ts +30 -0
- package/wait.js +30 -0
- package/wait.js.map +1 -0
- package/wait.ts +45 -0
- package/wake.js +552 -0
- package/wake.js.map +1 -0
- package/wake.ts +597 -0
- package/watch.js +520 -0
- package/watch.js.map +1 -0
- package/watch.ts +596 -0
- package/who.js +309 -0
- package/who.js.map +1 -0
- package/who.ts +347 -0
- package/window.js +179 -0
- package/window.js.map +1 -0
- package/window.ts +268 -0
- package/woken.js +129 -0
- package/woken.js.map +1 -0
- package/woken.ts +127 -0
package/hooks.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.js","sources":["./hooks.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,8EAA8E;AAC9E,4EAA4E;AAC5E,qEAAqE;AACrE,EAAE;AACF,8EAA8E;AAC9E,6EAA6E;AAC7E,8EAA8E;AAC9E,gEAAgE;AAChE,mBAAmB;AAEnB,YAAY,6BAAkC;AAC9C,YAAY,+CAAoD;AAChE,SAAS,WAAW,2BAAgC;AAEpD,SAAS,MAAM,iCAAsC;AACrD,SAAS,IAAI,EAAE,MAAM,sBAAqB;AAE1C;;kBAEkB,GAClB,OAAO,IAAI,SAAS,UAAS;AAE7B,oEAAoE;AACpE,IAAI,MAAM,IACR,YAAY,UAAU,CAAC,OAAS,cAAc,GAAG,CAAC,GAAG,CAAC,UAAU;AAElE;;4DAE4D,GAC5D,OAAO,IAAI,aAAa,CACtB,UAAU,KAAK,EACf,OAAO,cAAc,GAAG,CAAC,GAAG,CAAC,OAAO,GAEpC,WAAW,GAAG,KAAK,QAAQ,CAAC,GACxB,GAAG,KAAK,aAAa,CAAC,GACtB,GAAG,QAAQ,aAAa,CAAC,CAAA;AAM/B,sEAAsE,GACtE,OAAO,IAAI,aAAa,CAAC,QAAgB,MAAM,K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AK;EAC7C,GAAG,iBAAiB,CAAC,MAAM,GAAG,KAAK,SAAS,CAAC,MAAM,MAAM,GAAG,EAAE,CAAC;EAC/D,OAAO;IAAE;IAAM;IAAQ;EAAK;AAC9B,EAAC"}
|
package/hooks.ts
ADDED
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
// Lifecycle commands post to the running server, preserving its JSON stdout.
|
|
2
|
+
// Claude Code does not support HTTP SessionStart hooks. A small shell command
|
|
3
|
+
// keeps its additionalContext and retries through the local CLI on failure.
|
|
4
|
+
// The harness transcript remains the source of turns (./service.ts).
|
|
5
|
+
//
|
|
6
|
+
// The MCP connection names its session on every call it makes (`connection`),
|
|
7
|
+
// so a write is stamped with its caller whether or not that call's hook ever
|
|
8
|
+
// arrives. The `PreToolUse` hook still says which subagent made a call, which
|
|
9
|
+
// one connection serving a session and all its subagents cannot
|
|
10
|
+
// (./announce.ts).
|
|
11
|
+
|
|
12
|
+
import * as fs from '@yaks/file/io'
|
|
13
|
+
import * as systemProcess from '@yaks/process/system'
|
|
14
|
+
import { accountHome } from '@yaks/model'
|
|
15
|
+
|
|
16
|
+
import { served } from '@yaks/api/address'
|
|
17
|
+
import { PATH, STATUS } from './routes.js'
|
|
18
|
+
|
|
19
|
+
/** The Claude Code plugin that carries these hooks and the MCP connection
|
|
20
|
+
* (plugins/yak), as an account's settings enable it: its name, then its
|
|
21
|
+
* marketplace's. */
|
|
22
|
+
export let PLUGIN = 'yak@yak'
|
|
23
|
+
|
|
24
|
+
// The Claude Code account this process signs in with (@yaks/model).
|
|
25
|
+
let own = (): string =>
|
|
26
|
+
accountHome('claude', (name) => systemProcess.env.get(name)) ?? '.claude'
|
|
27
|
+
|
|
28
|
+
/** Where a Claude Code account (its directory, this process's by default)
|
|
29
|
+
* keeps the MCP servers of every project: the default account beside its
|
|
30
|
+
* directory, in `~/.claude.json`, and any other inside it. */
|
|
31
|
+
export let configPath = (
|
|
32
|
+
account = own(),
|
|
33
|
+
home = systemProcess.env.get('HOME'),
|
|
34
|
+
): string =>
|
|
35
|
+
account == `${home}/.claude`
|
|
36
|
+
? `${home}/.claude.json`
|
|
37
|
+
: `${account}/.claude.json`
|
|
38
|
+
|
|
39
|
+
/** What Claude Code starts beside itself to speak to this graph's MCP door.
|
|
40
|
+
* The client owns local file input; the HTTP server receives only values. */
|
|
41
|
+
export type Connection = { type: 'stdio'; command: string; args: string[] }
|
|
42
|
+
|
|
43
|
+
/** The local client for the MCP door of the `yak serve` at `server`. */
|
|
44
|
+
export let connection = (server: string, yak = 'yak'): Connection => ({
|
|
45
|
+
type: 'stdio',
|
|
46
|
+
command: yak,
|
|
47
|
+
args: ['mcp', '--host', server.replace(/\/+$/, '')],
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
// One door, however its host is spelled: `localhost` and `127.0.0.1` are the
|
|
51
|
+
// same server to everyone on this machine.
|
|
52
|
+
let LOOPBACK = ['localhost', '127.0.0.1', '[::1]']
|
|
53
|
+
let door = (url: unknown): string | undefined => {
|
|
54
|
+
if (typeof url != 'string' || !URL.canParse(url)) return
|
|
55
|
+
let u = new URL(url)
|
|
56
|
+
let host = LOOPBACK.includes(u.hostname) ? 'loopback' : u.hostname
|
|
57
|
+
return `${u.protocol}//${host}:${u.port}${u.pathname.replace(/\/+$/, '')}`
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
type Connected = { url?: string; command?: string; args?: string[] }
|
|
61
|
+
|
|
62
|
+
let connectedDoor = (entry: Connected): string | undefined => {
|
|
63
|
+
if (entry.url) return door(entry.url)
|
|
64
|
+
let args = entry.args ?? []
|
|
65
|
+
let host = args.indexOf('--host')
|
|
66
|
+
return entry.command && args[0] == 'mcp' && host >= 0
|
|
67
|
+
? door(`${args[host + 1]?.replace(/\/+$/, '')}/mcp`)
|
|
68
|
+
: undefined
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Write the connection into Claude Code's config, keeping everything else in
|
|
73
|
+
* it: the first entry already on this door is replaced under its own name and
|
|
74
|
+
* any other on it taken out, else it is added as `name`. `remove` takes them
|
|
75
|
+
* all out. Answers the name it is under.
|
|
76
|
+
*/
|
|
77
|
+
export let connect = (
|
|
78
|
+
path: string,
|
|
79
|
+
opts: { server: string; name?: string; yak?: string; remove?: boolean },
|
|
80
|
+
): string => {
|
|
81
|
+
let config: Record<string, unknown> = {}
|
|
82
|
+
try {
|
|
83
|
+
config = JSON.parse(fs.readTextFileSync(path))
|
|
84
|
+
} catch (e) {
|
|
85
|
+
if (!fs.isNotFound(e)) throw e
|
|
86
|
+
}
|
|
87
|
+
let entry = connection(opts.server, opts.yak)
|
|
88
|
+
let servers = { ...config.mcpServers as Record<string, Connected> }
|
|
89
|
+
let ours = Object.keys(servers)
|
|
90
|
+
.filter((n) => connectedDoor(servers[n]) == connectedDoor(entry))
|
|
91
|
+
let name = ours[0] ?? opts.name ?? 'yak'
|
|
92
|
+
for (let n of ours) delete servers[n]
|
|
93
|
+
if (!opts.remove) servers[name] = entry
|
|
94
|
+
fs.writeTextFileSync(
|
|
95
|
+
path,
|
|
96
|
+
`${JSON.stringify({ ...config, mcpServers: servers }, null, 2)}\n`,
|
|
97
|
+
)
|
|
98
|
+
return name
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** One lifecycle entry, in the form a harness settings file stores it. */
|
|
102
|
+
export type Hook = {
|
|
103
|
+
/** the tool names it runs for, a pattern the harness matches */
|
|
104
|
+
matcher?: string
|
|
105
|
+
hooks: (
|
|
106
|
+
| { type: 'command'; command: string; timeout?: number }
|
|
107
|
+
| { type: 'http'; url: string; timeout?: number }
|
|
108
|
+
)[]
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** Where the entries go for a Claude Code account, this process's by
|
|
112
|
+
* default, unless the caller names another path. */
|
|
113
|
+
export let settingsPath = (account = own()): string =>
|
|
114
|
+
`${account}/settings.json`
|
|
115
|
+
|
|
116
|
+
let cmd = (command: string, timeout?: number): Hook => ({
|
|
117
|
+
hooks: [{
|
|
118
|
+
type: 'command',
|
|
119
|
+
command,
|
|
120
|
+
...(timeout == null ? {} : { timeout }),
|
|
121
|
+
}],
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
// A hook posted to a server: a server that is down costs the harness the
|
|
125
|
+
// timeout and nothing else.
|
|
126
|
+
let post = (url: string, matcher?: string): Hook => ({
|
|
127
|
+
...(matcher ? { matcher } : {}),
|
|
128
|
+
hooks: [{ type: 'http', url, timeout: 2 }],
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
// Keep a failed/partial HTTP response out of stdout before trying the CLI, if
|
|
132
|
+
// there is one to try. `door` is a shell word.
|
|
133
|
+
let quote = (s: string) => "'" + s.replaceAll("'", "'\"'\"'") + "'"
|
|
134
|
+
let relay = (door: string, fallback?: string, timeout?: number): Hook =>
|
|
135
|
+
cmd(
|
|
136
|
+
'payload=$(cat); ' +
|
|
137
|
+
'via=${CLAUDE_CODE_SESSION_ID:-${TASKS_SESSION:-${CODEX_THREAD_ID:-}}}; ' +
|
|
138
|
+
'case "${CLAUDE_CODE_SESSION_ID:+${AI_AGENT:-}}" in *_agent) ' +
|
|
139
|
+
'case "$PWD" in */.claude/worktrees/agent-*) ' +
|
|
140
|
+
'agent=${PWD##*/.claude/worktrees/agent-}; agent=${agent%%/*}; ' +
|
|
141
|
+
'case "$agent" in \'\'|*[!0-9a-f]*) ;; *) via=$agent ;; esac ;; esac ;; esac; ' +
|
|
142
|
+
'if answer=$(printf %s "$payload" | curl --fail --silent ' +
|
|
143
|
+
'--connect-timeout 0.1 --max-time 2 ' +
|
|
144
|
+
'--header "x-via: $via" ' +
|
|
145
|
+
"--header 'content-type: application/json' --data-binary @- " +
|
|
146
|
+
door + '); then printf \'%s\\n\' "$answer"; ' +
|
|
147
|
+
(fallback ? `else printf %s "$payload" | ${fallback} || true; fi` : 'fi'),
|
|
148
|
+
timeout,
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
// The entries, posting to the hook door at `door`: a URL, or a shell word
|
|
152
|
+
// that names it, where every entry is then a command (a plugin's hooks read
|
|
153
|
+
// its options from their environment, which an HTTP hook's URL cannot).
|
|
154
|
+
let entries = (
|
|
155
|
+
door: { url: string } | { word: string },
|
|
156
|
+
yak: string,
|
|
157
|
+
): Record<string, Hook[]> => {
|
|
158
|
+
let word = 'url' in door ? quote(door.url) : door.word
|
|
159
|
+
let send = (matcher?: string): Hook =>
|
|
160
|
+
'url' in door
|
|
161
|
+
? post(door.url, matcher)
|
|
162
|
+
: { ...(matcher ? { matcher } : {}), ...relay(word) }
|
|
163
|
+
return {
|
|
164
|
+
SessionStart: [relay(word, `${yak} session context --hook -`)],
|
|
165
|
+
SubagentStart: [relay(word, `${yak} session context --hook -`)],
|
|
166
|
+
UserPromptSubmit: [relay(word, `${yak} session context --hook -`, 5)],
|
|
167
|
+
PreToolUse: [send('mcp__.*')],
|
|
168
|
+
PostToolUse: [send()],
|
|
169
|
+
Stop: [send()],
|
|
170
|
+
SessionEnd: [relay(word, `${yak} session wrap --hook -`, 5)],
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* The entries this package owns, keyed by the harness event each responds to.
|
|
176
|
+
*
|
|
177
|
+
* `server` is the origin of the `yak serve` the hook door is on. `yak` is the
|
|
178
|
+
* path to the command on this machine — a full path where it is not on the
|
|
179
|
+
* harness's path.
|
|
180
|
+
*/
|
|
181
|
+
export let lifecycle = (
|
|
182
|
+
server: string,
|
|
183
|
+
yak = 'yak',
|
|
184
|
+
): Record<string, Hook[]> =>
|
|
185
|
+
entries({ url: `${server.replace(/\/+$/, '')}${PATH}` }, yak)
|
|
186
|
+
|
|
187
|
+
/** The plugin's option naming the `yak serve` its hooks and MCP connection
|
|
188
|
+
* reach, as its hooks read it from their environment. */
|
|
189
|
+
export let SERVER = 'CLAUDE_PLUGIN_OPTION_SERVER'
|
|
190
|
+
|
|
191
|
+
/** The same entries as the plugin carries them (plugins/yak/hooks/hooks.json):
|
|
192
|
+
* the door is the server its `server` option names, else the one `yak serve`
|
|
193
|
+
* listens at by default. */
|
|
194
|
+
export let pluginHooks = (yak = 'yak'): Record<string, Hook[]> =>
|
|
195
|
+
entries({ word: `"\${${SERVER}:-${served({})}}"${PATH}` }, yak)
|
|
196
|
+
|
|
197
|
+
/** The status line entry: Claude Code hands what it knows to the server's
|
|
198
|
+
* status door, which keeps the plan readings and answers the line
|
|
199
|
+
* (./statusline.ts). A server that is down leaves the line empty. */
|
|
200
|
+
export let statusLine = (server: string) => ({
|
|
201
|
+
type: 'command',
|
|
202
|
+
command: 'curl --fail --silent --connect-timeout 0.1 --max-time 1 ' +
|
|
203
|
+
"--header 'content-type: application/json' --data-binary @- " +
|
|
204
|
+
quote(`${server.replace(/\/+$/, '')}${STATUS}`),
|
|
205
|
+
padding: 0,
|
|
206
|
+
})
|
|
207
|
+
|
|
208
|
+
let ourLine = (line: unknown) =>
|
|
209
|
+
String((line as { command?: string } | undefined)?.command ?? '')
|
|
210
|
+
.includes(STATUS)
|
|
211
|
+
|
|
212
|
+
// Ours, identified by the command it runs or the door it posts to, including
|
|
213
|
+
// the turn hooks an older install wrote (`session/turn.ts`), which an install
|
|
214
|
+
// now takes out. A person's own entry never runs either.
|
|
215
|
+
let MINE =
|
|
216
|
+
/\byak\b.*\bsession (context|wrap) --hook\b|\bsession\b\S*\/turn\.ts\b/
|
|
217
|
+
let mine = (h: unknown): boolean =>
|
|
218
|
+
((h as Hook | undefined)?.hooks ?? []).some((
|
|
219
|
+
x: { url?: string; command?: string },
|
|
220
|
+
) => !!x?.url?.endsWith(PATH) || MINE.test(x?.command ?? ''))
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* The lifecycle entries merged into the hooks a settings file already had:
|
|
224
|
+
* ours lead each event, everything else follows, and an earlier install of
|
|
225
|
+
* ours is replaced rather than doubled. `gone` removes ours and keeps the
|
|
226
|
+
* rest.
|
|
227
|
+
*/
|
|
228
|
+
export let merged = (
|
|
229
|
+
had: Record<string, unknown> | undefined,
|
|
230
|
+
add: Record<string, Hook[]>,
|
|
231
|
+
gone = false,
|
|
232
|
+
): Record<string, unknown[]> => {
|
|
233
|
+
let out: Record<string, unknown[]> = {}
|
|
234
|
+
for (let event of new Set([...Object.keys(had ?? {}), ...Object.keys(add)])) {
|
|
235
|
+
let was = had?.[event]
|
|
236
|
+
let kept = (Array.isArray(was) ? was : []).filter((h) => !mine(h))
|
|
237
|
+
let ours = gone ? [] : add[event] ?? []
|
|
238
|
+
if (kept.length || ours.length) out[event] = [...ours, ...kept]
|
|
239
|
+
}
|
|
240
|
+
return out
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/** What an install did to one Claude Code account. */
|
|
244
|
+
export type Installed = {
|
|
245
|
+
/** the settings file written */
|
|
246
|
+
path: string
|
|
247
|
+
/** whether the account runs the plugin, which carries the hooks and the
|
|
248
|
+
* MCP connection in their place */
|
|
249
|
+
plugin: boolean
|
|
250
|
+
/** whether the status line is ours */
|
|
251
|
+
line: boolean
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/** What an install tells the person who ran it: what changed, and what to do
|
|
255
|
+
* next for Claude Code to work with this graph. */
|
|
256
|
+
export let installed = (
|
|
257
|
+
done: Installed,
|
|
258
|
+
server: string,
|
|
259
|
+
removed = false,
|
|
260
|
+
mcp?: { path: string; name: string },
|
|
261
|
+
): string =>
|
|
262
|
+
removed
|
|
263
|
+
? [
|
|
264
|
+
`removed this graph's session hooks and status line from ${done.path}`,
|
|
265
|
+
...mcp ? [`and its MCP server ${mcp.name} from ${mcp.path}`] : [],
|
|
266
|
+
].join('\n')
|
|
267
|
+
: [
|
|
268
|
+
done.plugin
|
|
269
|
+
? `${done.path} runs the ${PLUGIN} plugin, which carries the hooks ` +
|
|
270
|
+
`and this graph's tools: it now reaches ${server}, and the hooks ` +
|
|
271
|
+
'and MCP server an earlier install wrote by hand are gone.'
|
|
272
|
+
: `wrote the session hooks into ${done.path}.`,
|
|
273
|
+
...mcp && !done.plugin
|
|
274
|
+
? [
|
|
275
|
+
`wrote this graph's tools into ${mcp.path} as the MCP server ` +
|
|
276
|
+
`${mcp.name}, each call naming its session.`,
|
|
277
|
+
]
|
|
278
|
+
: [],
|
|
279
|
+
done.line
|
|
280
|
+
? "the status line shows each plan's room."
|
|
281
|
+
: 'the status line is your own, so it is left as it was.',
|
|
282
|
+
'A Claude Code session started from now on, in any directory, is a ' +
|
|
283
|
+
'session in this graph.',
|
|
284
|
+
`next: yak serve, which the hooks post each tool call to (${server}${PATH}).`,
|
|
285
|
+
].join('\n')
|
|
286
|
+
|
|
287
|
+
/** Write the entries and the status line into a settings file, keeping
|
|
288
|
+
* everything else in it; where the account runs the plugin, point it at
|
|
289
|
+
* `server` and take out the entries an earlier install wrote, which the
|
|
290
|
+
* plugin carries. A status line of the person's own stays. */
|
|
291
|
+
export let install = (
|
|
292
|
+
path: string,
|
|
293
|
+
opts: { server: string; yak?: string; remove?: boolean },
|
|
294
|
+
): Installed => {
|
|
295
|
+
let settings: Record<string, unknown> = {}
|
|
296
|
+
try {
|
|
297
|
+
settings = JSON.parse(fs.readTextFileSync(path))
|
|
298
|
+
} catch (e) {
|
|
299
|
+
if (!fs.isNotFound(e)) throw e
|
|
300
|
+
}
|
|
301
|
+
let plugin =
|
|
302
|
+
!!(settings.enabledPlugins as Record<string, unknown> | undefined)
|
|
303
|
+
?.[PLUGIN]
|
|
304
|
+
let hooks = merged(
|
|
305
|
+
settings.hooks as Record<string, unknown> | undefined,
|
|
306
|
+
lifecycle(opts.server, opts.yak),
|
|
307
|
+
opts.remove || plugin,
|
|
308
|
+
)
|
|
309
|
+
let next: Record<string, unknown> = { ...settings, hooks }
|
|
310
|
+
if (!Object.keys(hooks).length) delete next.hooks
|
|
311
|
+
let line = !settings.statusLine || ourLine(settings.statusLine)
|
|
312
|
+
if (line && opts.remove) delete next.statusLine
|
|
313
|
+
else if (line) next.statusLine = statusLine(opts.server)
|
|
314
|
+
if (plugin && !opts.remove) {
|
|
315
|
+
let configs = settings.pluginConfigs as
|
|
316
|
+
| Record<string, { options?: Record<string, unknown> }>
|
|
317
|
+
| undefined
|
|
318
|
+
next.pluginConfigs = {
|
|
319
|
+
...configs,
|
|
320
|
+
[PLUGIN]: {
|
|
321
|
+
...configs?.[PLUGIN],
|
|
322
|
+
options: {
|
|
323
|
+
...configs?.[PLUGIN]?.options,
|
|
324
|
+
server: opts.server.replace(/\/+$/, ''),
|
|
325
|
+
},
|
|
326
|
+
},
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
let dir = path.slice(0, path.lastIndexOf('/'))
|
|
330
|
+
if (dir) fs.mkdirSync(dir, { recursive: true })
|
|
331
|
+
fs.writeTextFileSync(path, `${JSON.stringify(next, null, 2)}\n`)
|
|
332
|
+
return { path, plugin, line }
|
|
333
|
+
}
|
package/imported.js
ADDED
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
// One line of a harness's log, as the rows it becomes: what the importer
|
|
2
|
+
// (./tail.ts) writes for each line it reads, and what a host handed a run's
|
|
3
|
+
// lines rather than its file writes the same way (@yaks/spawn ./machines.ts).
|
|
4
|
+
// It reads no file, so a Worker imports it.
|
|
5
|
+
import { derivedEid, identityEid } from "@yaks/graph/identity";
|
|
6
|
+
import { toolEid } from "@yaks/tools/result";
|
|
7
|
+
import { limitRows } from "@yaks/model";
|
|
8
|
+
/** The entity a harness's call becomes, named by the harness's own id for it,
|
|
9
|
+
* which is also what its result names. */ export let callOf = (session, id)=>derivedEid(`call ${session} ${id}`);
|
|
10
|
+
/** The entry a model request becomes, named by the harness's own id for it,
|
|
11
|
+
* which every line of its reply names again. */ export let askOf = (session, id)=>derivedEid(`ask ${session} ${id}`);
|
|
12
|
+
/**
|
|
13
|
+
* Whether an entry is prose: what a person typed (content alone), or what the
|
|
14
|
+
* model said (content and the output that marks it).
|
|
15
|
+
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { prose } from '@yaks/session/tail'
|
|
18
|
+
* import { assertEquals } from '@std/assert'
|
|
19
|
+
*
|
|
20
|
+
* assertEquals(prose({ content: { body: 'hi' } }), true)
|
|
21
|
+
* assertEquals(prose({ content: { body: 'hmm' }, reasoning: {}, output: {} }), false)
|
|
22
|
+
* ```
|
|
23
|
+
*/ export let prose = (c)=>!!c.content && Object.keys(c).every((k)=>k == 'content' || k == 'output' || !!c.checkpoint && (k == 'checkpoint' || k == 'notice'));
|
|
24
|
+
/** Selections retain the runner/model provenance of old imported sessions. */ export let retained = (c)=>prose(c) || !!c.using;
|
|
25
|
+
/** What a person typed: prose with no output beside it. */ export let typed = (c)=>prose(c) && !c.output && !c.checkpoint;
|
|
26
|
+
/** Two patches to one entity, as one. */ export let merge = (a, b)=>{
|
|
27
|
+
let out = {
|
|
28
|
+
...a
|
|
29
|
+
};
|
|
30
|
+
for (let [k, v] of Object.entries(b)){
|
|
31
|
+
out[k] = v && typeof v == 'object' && !Array.isArray(v) && out[k] ? {
|
|
32
|
+
...out[k],
|
|
33
|
+
...v
|
|
34
|
+
} : v;
|
|
35
|
+
}
|
|
36
|
+
return out;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* One line, as the bundles it becomes: an entry for each thing it says, each
|
|
40
|
+
* sitting at the line of the file it was read from, a row for each tool it
|
|
41
|
+
* names, the answered call's state, and what it says about the session. A
|
|
42
|
+
* prompt a person typed is signed by `person`.
|
|
43
|
+
*/ export let imported = (said, o)=>{
|
|
44
|
+
let { session, file, path, line } = o;
|
|
45
|
+
let key = o.own === false ? `${session} ${path}` : session;
|
|
46
|
+
let out = new Map();
|
|
47
|
+
let put = (b)=>{
|
|
48
|
+
let was = out.get(b.entity.eid);
|
|
49
|
+
out.set(b.entity.eid, was ? merge(was, b) : b);
|
|
50
|
+
};
|
|
51
|
+
// A request comes before what it returned, wherever its reader put it, so
|
|
52
|
+
// the reply ending a turn is its newest entry. Each entry keeps the name
|
|
53
|
+
// its place in the line gives it.
|
|
54
|
+
let asked = (c)=>c.ask?.id != null;
|
|
55
|
+
let order = said.entries.map((c, i)=>[
|
|
56
|
+
c,
|
|
57
|
+
i
|
|
58
|
+
]);
|
|
59
|
+
order = [
|
|
60
|
+
...order.filter(([c])=>asked(c)),
|
|
61
|
+
...order.filter(([c])=>!asked(c))
|
|
62
|
+
];
|
|
63
|
+
order.forEach(([c, i])=>{
|
|
64
|
+
if (o.prose && !retained(c)) return;
|
|
65
|
+
let { call, result, execution, output, using, ask, ...rest } = c;
|
|
66
|
+
let row = (name, value)=>{
|
|
67
|
+
let eid = identityEid(name, [
|
|
68
|
+
String(value)
|
|
69
|
+
]);
|
|
70
|
+
put({
|
|
71
|
+
entity: {
|
|
72
|
+
eid
|
|
73
|
+
},
|
|
74
|
+
[name]: {
|
|
75
|
+
name: String(value)
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
return eid;
|
|
79
|
+
};
|
|
80
|
+
if (using) {
|
|
81
|
+
let refs = {
|
|
82
|
+
...using
|
|
83
|
+
};
|
|
84
|
+
for (let name of [
|
|
85
|
+
'provider',
|
|
86
|
+
'model'
|
|
87
|
+
]){
|
|
88
|
+
if (using[name]) refs[name] = row(name, using[name]);
|
|
89
|
+
}
|
|
90
|
+
rest.using = refs;
|
|
91
|
+
}
|
|
92
|
+
let at = {
|
|
93
|
+
entry: {
|
|
94
|
+
session
|
|
95
|
+
},
|
|
96
|
+
...file ? {
|
|
97
|
+
lines: {
|
|
98
|
+
file,
|
|
99
|
+
start: line
|
|
100
|
+
}
|
|
101
|
+
} : {}
|
|
102
|
+
};
|
|
103
|
+
if (ask && ask.id == null) rest.ask = ask;
|
|
104
|
+
else if (ask) {
|
|
105
|
+
let { id, to, ...asked } = ask;
|
|
106
|
+
put({
|
|
107
|
+
entity: {
|
|
108
|
+
eid: askOf(session, String(id ?? `${line} ${i}`))
|
|
109
|
+
},
|
|
110
|
+
...at,
|
|
111
|
+
ask: {
|
|
112
|
+
...asked,
|
|
113
|
+
...to ? {
|
|
114
|
+
to: row('model', to)
|
|
115
|
+
} : {}
|
|
116
|
+
},
|
|
117
|
+
...rest
|
|
118
|
+
});
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
if (call) {
|
|
122
|
+
let { to, ...asked } = call;
|
|
123
|
+
let name = String(to ?? '');
|
|
124
|
+
if (name) put({
|
|
125
|
+
entity: {
|
|
126
|
+
eid: toolEid(name)
|
|
127
|
+
},
|
|
128
|
+
tool: {
|
|
129
|
+
name
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
put({
|
|
133
|
+
entity: {
|
|
134
|
+
eid: callOf(session, String(call.id))
|
|
135
|
+
},
|
|
136
|
+
...at,
|
|
137
|
+
// The name it was called by stays beside the tool it names: a
|
|
138
|
+
// provider that continues the conversation is not served that tool.
|
|
139
|
+
call: {
|
|
140
|
+
...asked,
|
|
141
|
+
...name ? {
|
|
142
|
+
to: toolEid(name),
|
|
143
|
+
name
|
|
144
|
+
} : {}
|
|
145
|
+
},
|
|
146
|
+
execution: {
|
|
147
|
+
by: session
|
|
148
|
+
},
|
|
149
|
+
...rest
|
|
150
|
+
});
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
let answers = result && callOf(session, String(result.call));
|
|
154
|
+
put({
|
|
155
|
+
entity: {
|
|
156
|
+
eid: derivedEid(`${key} ${line} ${i}`)
|
|
157
|
+
},
|
|
158
|
+
...at,
|
|
159
|
+
...answers ? {
|
|
160
|
+
result: {
|
|
161
|
+
...result,
|
|
162
|
+
call: answers
|
|
163
|
+
}
|
|
164
|
+
} : {},
|
|
165
|
+
...output ? {
|
|
166
|
+
output: {
|
|
167
|
+
...output,
|
|
168
|
+
source: session
|
|
169
|
+
}
|
|
170
|
+
} : {},
|
|
171
|
+
...rest,
|
|
172
|
+
...typed(c) && o.person ? {
|
|
173
|
+
$actor: {
|
|
174
|
+
by: o.person,
|
|
175
|
+
via: session
|
|
176
|
+
}
|
|
177
|
+
} : {}
|
|
178
|
+
});
|
|
179
|
+
if (answers && execution) put({
|
|
180
|
+
entity: {
|
|
181
|
+
eid: answers
|
|
182
|
+
},
|
|
183
|
+
execution
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
if (said.about) put({
|
|
187
|
+
entity: {
|
|
188
|
+
eid: session
|
|
189
|
+
},
|
|
190
|
+
...said.about
|
|
191
|
+
});
|
|
192
|
+
for (let b of limitRows(said.limits ?? [], said.at))put(b);
|
|
193
|
+
return [
|
|
194
|
+
...out.values()
|
|
195
|
+
];
|
|
196
|
+
};
|
|
197
|
+
/**
|
|
198
|
+
* What a line says once the run of parts before it is joined, each with the
|
|
199
|
+
* line its entries sit at: the run's entry at its first line, where this line
|
|
200
|
+
* ends the run, then the line's own. A part of the run's key carries the run
|
|
201
|
+
* on, and a part of another key starts one.
|
|
202
|
+
*
|
|
203
|
+
* ```ts
|
|
204
|
+
* import { pieced } from '@yaks/session/tail'
|
|
205
|
+
* import { assertEquals } from '@std/assert'
|
|
206
|
+
*
|
|
207
|
+
* let h = {}
|
|
208
|
+
* let piece = (body: string) => ({ entries: [], part: { key: 'r', entry: { content: { body } } } })
|
|
209
|
+
* pieced(h, piece('Hel'), 3)
|
|
210
|
+
* pieced(h, piece('lo'), 4)
|
|
211
|
+
* assertEquals(pieced(h, { entries: [{ stop: {} }] }, 5), [
|
|
212
|
+
* [{ entries: [{ content: { body: 'Hello' } }] }, 3],
|
|
213
|
+
* [{ entries: [{ stop: {} }] }, 5],
|
|
214
|
+
* ])
|
|
215
|
+
* ```
|
|
216
|
+
*/ export let pieced = (h, said, line)=>{
|
|
217
|
+
let { part, ...own } = said;
|
|
218
|
+
let open = h.part;
|
|
219
|
+
if (part && open?.key == part.key) {
|
|
220
|
+
let body = (c)=>String(c.content?.body ?? '');
|
|
221
|
+
open.entry = {
|
|
222
|
+
...open.entry,
|
|
223
|
+
content: {
|
|
224
|
+
body: body(open.entry) + body(part.entry)
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
return [
|
|
228
|
+
[
|
|
229
|
+
own,
|
|
230
|
+
line
|
|
231
|
+
]
|
|
232
|
+
];
|
|
233
|
+
}
|
|
234
|
+
h.part = part && {
|
|
235
|
+
key: part.key,
|
|
236
|
+
line,
|
|
237
|
+
entry: part.entry
|
|
238
|
+
};
|
|
239
|
+
return open ? [
|
|
240
|
+
[
|
|
241
|
+
{
|
|
242
|
+
entries: [
|
|
243
|
+
open.entry
|
|
244
|
+
]
|
|
245
|
+
},
|
|
246
|
+
open.line
|
|
247
|
+
],
|
|
248
|
+
[
|
|
249
|
+
own,
|
|
250
|
+
line
|
|
251
|
+
]
|
|
252
|
+
] : [
|
|
253
|
+
[
|
|
254
|
+
own,
|
|
255
|
+
line
|
|
256
|
+
]
|
|
257
|
+
];
|
|
258
|
+
};
|
|
259
|
+
//# sourceMappingURL=imported.js.map
|
package/imported.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imported.js","sources":["./imported.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,4EAA4E;AAC5E,8EAA8E;AAC9E,4CAA4C;AAG5C,SAAS,UAAU,EAAE,WAAW,oCAAyC;AACzE,SAAS,OAAO,kCAAuC;AACvD,SAAS,SAAS,2BAAgC;AAGlD;wCACwC,GACxC,OAAO,IAAI,SAAS,CAAC,SAAc,KACjC,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC,EAAE,IAAI,EAAC;AAErC;8CAC8C,GAC9C,OAAO,IAAI,QAAQ,CAAC,SAAc,KAChC,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,IAAI,EAAC;AAEpC;;;;;;;;;;;CAWC,GACD,OAAO,IAAI,QAAQ,CAAC,IAClB,CAAC,CAAC,EAAE,OAAO,IAAI,OAAO,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,IACnC,KAAK,aAAa,KAAK,YACtB,CAAC,CAAC,EAAE,UAAU,IAAI,CAAC,KAAK,gBAAgB,KAAK,QAAQ,GACvD;AAEH,4EAA4E,GAC5E,OAAO,IAAI,WAAW,CAAC,IAAa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