@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/talk.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A session drawn as its conversation, wherever a host asks the registry for
|
|
3
|
+
* its `Conversation` view: it asks for the session's entries, makes them
|
|
4
|
+
* lines with `joined`, draws each with the kinds of ./conversation.ts, and
|
|
5
|
+
* hands them to @yaks/ux's `Conversation`, which holds where its reader is.
|
|
6
|
+
* A host with words of its own (the Operator's) registers a more specific
|
|
7
|
+
* `Conversation` view of its own.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/ /* @ts-types="npm:@types/react@19.3.0" */ import { createElement as h } from "react";
|
|
11
|
+
import { parse } from "@yaks/query/core";
|
|
12
|
+
import { Conversation, conversationAt } from "@yaks/ux";
|
|
13
|
+
import { draw, joined, kinds, namer } from "./conversation.js";
|
|
14
|
+
import { ENTRY } from "./native.js";
|
|
15
|
+
import { SESSION } from "./comp.js";
|
|
16
|
+
/** What it asks for: the session's entries, in its order. */ export let asked = (session)=>`.${ENTRY}.session=${session}&*&.order=${ENTRY}.seq`;
|
|
17
|
+
// The session's entries, each line drawn as every transcript draws it.
|
|
18
|
+
let Talk = ({ e, io })=>{
|
|
19
|
+
let session = e.entity.eid;
|
|
20
|
+
let got = io.ask({
|
|
21
|
+
entries: asked(session)
|
|
22
|
+
});
|
|
23
|
+
let names = namer({});
|
|
24
|
+
let lines = joined(got.entries?.rows ?? []).flatMap(({ entry, result })=>{
|
|
25
|
+
let said = draw(kinds, entry, {
|
|
26
|
+
result,
|
|
27
|
+
names
|
|
28
|
+
});
|
|
29
|
+
return said ? [
|
|
30
|
+
{
|
|
31
|
+
id: entry.entity.eid,
|
|
32
|
+
node: said.node,
|
|
33
|
+
transient: said.tone == 'on'
|
|
34
|
+
}
|
|
35
|
+
] : [];
|
|
36
|
+
});
|
|
37
|
+
let at = conversationAt('session', session);
|
|
38
|
+
return /*#__PURE__*/ h(Conversation, {
|
|
39
|
+
e: io.state(at) ?? {
|
|
40
|
+
entity: {
|
|
41
|
+
eid: at
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
onChange: (b)=>io.set([
|
|
45
|
+
b
|
|
46
|
+
]),
|
|
47
|
+
state: io.state,
|
|
48
|
+
lines
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
/** A session as its conversation. */ export let conversationViews = [
|
|
52
|
+
{
|
|
53
|
+
view: 'Conversation',
|
|
54
|
+
match: parse(`.${SESSION}`),
|
|
55
|
+
Render: Talk
|
|
56
|
+
}
|
|
57
|
+
];
|
|
58
|
+
//# sourceMappingURL=talk.js.map
|
package/talk.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"talk.js","sources":["./talk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;CASC,GAED,uCAAuC,GAAG,SAAS,iBAAiB,CAAC,gBAAoC;AACzG,SAAS,KAAK,gCAAqC;AAEnD,SAAS,YAAY,EAAE,cAAc,wBAA6B;AAClE,SAAS,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,4BAA2B;AAC9D,SAAS,KAAK,sBAAqB;AACnC,SAAS,OAAO,oBAAmB;AAEnC,2DAA2D,GAC3D,OAAO,IAAI,QAAQ,CAAC,UAClB,CAAC,CAAC,EAAE,MAAM,SAAS,EAAE,QAAQ,UAAU,EAAE,MAAM,IAAI,CAAC,CAAA;AAEtD,uEAAuE;AACvE,IAAI,OAAO,CAAC,EAAE,CAAC,EAAE,EAAE,EAAS;EAC1B,IAAI,UAAU,EAAE,MAAM,CAAC,GAAG;EAC1B,IAAI,MAAM,GAAG,GAAG,CAAC;IAAE,SAAS,MAAM;EAAS;EAC3C,IAAI,QAAQ,MAAM,CAAC;EACnB,IAAI,QAAQ,OAAO,IAAI,OAAO,EAAE,QAAQ,EAAE,EAAE,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE;IACpE,IAAI,OAAO,KAAK,OAAO,OAAO;MAAE;MAAQ;IAAM;IAC9C,OAAO,OACH;MAAC;QACD,IAAI,MAAM,MAAM,CAAC,GAAG;QACpB,MAAM,KAAK,IAAI;QACf,WAAW,KAAK,IAAI,IAAI;MAC1B;KAAE,GACA,EAAE;EACR;EACA,IAAI,KAAK,eAAe,WAAW;EACnC,qBAAO,EAAE,cAAc;IACrB,GAAG,GAAG,KAAK,CAAC,OAAO;MAAE,QAAQ;QAAE,KAAK;MAAG;IAAE;IACzC,UAAU,CAAC,IAAM,GAAG,GAAG,CAAC;QAAC;OAAE;IAC3B,OAAO,GAAG,KAAK;IACf;EACF;AACF;AAEA,mCAAmC,GACnC,OAAO,IAAI,oBAA4B;EACrC;IAAE,MAAM;IAAgB,OAAO,MAAM,CAAC,CAAC,EAAE,SAAS;IAAG,QAAQ;EAAK;CACnE,CAAA"}
|
package/talk.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A session drawn as its conversation, wherever a host asks the registry for
|
|
3
|
+
* its `Conversation` view: it asks for the session's entries, makes them
|
|
4
|
+
* lines with `joined`, draws each with the kinds of ./conversation.ts, and
|
|
5
|
+
* hands them to @yaks/ux's `Conversation`, which holds where its reader is.
|
|
6
|
+
* A host with words of its own (the Operator's) registers a more specific
|
|
7
|
+
* `Conversation` view of its own.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/* @ts-types="npm:@types/react@19.3.0" */ import { createElement as h, type JSX } from 'react'
|
|
13
|
+
import { parse } from '@yaks/query/core'
|
|
14
|
+
import type { Props, View } from 'jsr:@yaks/inspect@0.2.36'
|
|
15
|
+
import { Conversation, conversationAt } from '@yaks/ux'
|
|
16
|
+
import { draw, joined, kinds, namer } from './conversation.js'
|
|
17
|
+
import { ENTRY } from './native.js'
|
|
18
|
+
import { SESSION } from './comp.js'
|
|
19
|
+
|
|
20
|
+
/** What it asks for: the session's entries, in its order. */
|
|
21
|
+
export let asked = (session: string): string =>
|
|
22
|
+
`.${ENTRY}.session=${session}&*&.order=${ENTRY}.seq`
|
|
23
|
+
|
|
24
|
+
// The session's entries, each line drawn as every transcript draws it.
|
|
25
|
+
let Talk = ({ e, io }: Props): JSX.Element => {
|
|
26
|
+
let session = e.entity.eid
|
|
27
|
+
let got = io.ask({ entries: asked(session) })
|
|
28
|
+
let names = namer({})
|
|
29
|
+
let lines = joined(got.entries?.rows ?? []).flatMap(({ entry, result }) => {
|
|
30
|
+
let said = draw(kinds, entry, { result, names })
|
|
31
|
+
return said
|
|
32
|
+
? [{
|
|
33
|
+
id: entry.entity.eid,
|
|
34
|
+
node: said.node,
|
|
35
|
+
transient: said.tone == 'on',
|
|
36
|
+
}]
|
|
37
|
+
: []
|
|
38
|
+
})
|
|
39
|
+
let at = conversationAt('session', session)
|
|
40
|
+
return h(Conversation, {
|
|
41
|
+
e: io.state(at) ?? { entity: { eid: at } },
|
|
42
|
+
onChange: (b) => io.set([b]),
|
|
43
|
+
state: io.state,
|
|
44
|
+
lines,
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** A session as its conversation. */
|
|
49
|
+
export let conversationViews: View[] = [
|
|
50
|
+
{ view: 'Conversation', match: parse(`.${SESSION}`), Render: Talk },
|
|
51
|
+
]
|
package/task-context.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// A checkpoint freezes claimed task specifications. Later edits and claim
|
|
2
|
+
// changes are appended as context, never rewritten into the cached prefix.
|
|
3
|
+
import { message } from "@yaks/model";
|
|
4
|
+
import { seqOf } from "./state.js";
|
|
5
|
+
export let snapshot = (rows)=>Object.fromEntries(rows.toSorted((a, b)=>a.entity.eid.localeCompare(b.entity.eid)).map((b)=>{
|
|
6
|
+
let doc = b.doc;
|
|
7
|
+
return [
|
|
8
|
+
b.entity.eid,
|
|
9
|
+
{
|
|
10
|
+
...doc?.title == null ? {} : {
|
|
11
|
+
title: String(doc.title)
|
|
12
|
+
},
|
|
13
|
+
...doc?.body == null ? {} : {
|
|
14
|
+
body: String(doc.body)
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
];
|
|
18
|
+
}));
|
|
19
|
+
export let spec = (doc)=>[
|
|
20
|
+
doc.title,
|
|
21
|
+
doc.body
|
|
22
|
+
].filter((v)=>v != null).join('\n\n');
|
|
23
|
+
export let items = (tasks)=>Object.entries(tasks).map(([eid, doc])=>message({
|
|
24
|
+
kind: 'instruction',
|
|
25
|
+
text: 'Claimed task ' + eid + '\n' + spec(doc)
|
|
26
|
+
}, 'the system (claimed task specification)'));
|
|
27
|
+
/** The newest admitted task set since this checkpoint, not live graph rows. */ export let admitted = (entries, checkpoint)=>{
|
|
28
|
+
let later = entries.filter((b)=>seqOf(b) > seqOf(checkpoint) && b.task_context?.checkpoint == checkpoint.entity.eid).at(-1);
|
|
29
|
+
return (later?.task_context ?? checkpoint.checkpoint).tasks ?? {};
|
|
30
|
+
};
|
|
31
|
+
/** New or edited specs in full, releases as explicit context corrections. */ export let changes = (before, after)=>[
|
|
32
|
+
...new Set([
|
|
33
|
+
...Object.keys(before),
|
|
34
|
+
...Object.keys(after)
|
|
35
|
+
])
|
|
36
|
+
].sort().flatMap((eid)=>JSON.stringify(before[eid]) == JSON.stringify(after[eid]) ? [] : after[eid] ? [
|
|
37
|
+
'Claimed task ' + eid + '\n' + spec(after[eid])
|
|
38
|
+
] : [
|
|
39
|
+
'Released task ' + eid + ': no longer claimed by this session.'
|
|
40
|
+
]).join('\n\n');
|
|
41
|
+
//# sourceMappingURL=task-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task-context.js","sources":["./task-context.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,2EAA2E;AAG3E,SAAoB,OAAO,2BAAgC;AAC3D,SAAS,KAAK,qBAAoB;AAIlC,OAAO,IAAI,WAAW,CAAC,OACrB,OAAO,WAAW,CAChB,KAAK,QAAQ,CAAC,CAAC,GAAG,IAAM,EAAE,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC,GAAG,GAAG,GAAG,CACnE,CAAC;IACC,IAAI,MAAM,EAAE,GAAG;IACf,OAAO;MAAC,EAAE,MAAM,CAAC,GAAG;MAAE;QACpB,GAAG,KAAK,SAAS,OAAO,CAAC,IAAI;UAAE,OAAO,OAAO,IAAI,KAAK;QAAE,CAAC;QACzD,GAAG,KAAK,QAAQ,OAAO,CAAC,IAAI;UAAE,MAAM,OAAO,IAAI,IAAI;QAAE,CAAC;MACxD;KAAE;EACJ,IAEH;AAEH,OAAO,IAAI,OAAO,CAAC,MACjB;IAAC,IAAI,KAAK;IAAE,IAAI,IAAI;GAAC,CAAC,MAAM,CAAC,CAAC,IAAM,KAAK,MAAM,IAAI,CAAC,QAAO;AAE7D,OAAO,IAAI,QAAQ,CAAC,QAClB,OAAO,OAAO,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,KAAK,IAAI,GACnC,QAAQ;MACN,MAAM;MACN,MAAM,kBAAkB,MAAM,OAAO,KAAK;IAC5C,GAAG,4CACJ;AAEH,6EAA6E,GAC7E,OAAO,IAAI,WAAW,CAAC,SAAmB;EACxC,IAAI,QAAQ,QAAQ,MAAM,CAAC,CAAC,IAC1B,MAAM,KAAK,MAAM,eACjB,AAAC,EAAE,YAAY,EAAuB,cAAc,WAAW,MAAM,CAAC,GAAG,EACzE,EAAE,CAAC,CAAC;EACN,OAAO,AAAC,CAAC,OAAO,gBAAgB,WAAW,UAAU,EAClD,KAAK,IAAa,CAAC;AACxB,EAAC;AAED,2EAA2E,GAC3E,OAAO,IAAI,UAAU,CAAC,QAAe,QACnC;OAAI,IAAI,IAAI;SAAI,OAAO,IAAI,CAAC;SAAY,OAAO,IAAI,CAAC;KAAO;GAAE,CAAC,IAAI,GAC/D,OAAO,CAAC,CAAC,MACR,KAAK,SAAS,CAAC,MAAM,CAAC,IAAI,KAAK,KAAK,SAAS,CAAC,KAAK,CAAC,IAAI,IACpD,EAAE,GACF,KAAK,CAAC,IAAI,GACV;MAAC,kBAAkB,MAAM,OAAO,KAAK,KAAK,CAAC,IAAI;KAAE,GACjD;MAAC,mBAAmB,MAAM;KAAuC,EACrE,IAAI,CAAC,QAAO"}
|
package/task-context.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// A checkpoint freezes claimed task specifications. Later edits and claim
|
|
2
|
+
// changes are appended as context, never rewritten into the cached prefix.
|
|
3
|
+
|
|
4
|
+
import type { Bundle, Comp } from 'jsr:@yaks/graph@0.2.36'
|
|
5
|
+
import { type Item, message } from '@yaks/model'
|
|
6
|
+
import { seqOf } from './state.js'
|
|
7
|
+
|
|
8
|
+
export type Tasks = Record<string, { title?: string; body?: string }>
|
|
9
|
+
|
|
10
|
+
export let snapshot = (rows: Bundle[]): Tasks =>
|
|
11
|
+
Object.fromEntries(
|
|
12
|
+
rows.toSorted((a, b) => a.entity.eid.localeCompare(b.entity.eid)).map(
|
|
13
|
+
(b) => {
|
|
14
|
+
let doc = b.doc as Comp | undefined
|
|
15
|
+
return [b.entity.eid, {
|
|
16
|
+
...doc?.title == null ? {} : { title: String(doc.title) },
|
|
17
|
+
...doc?.body == null ? {} : { body: String(doc.body) },
|
|
18
|
+
}]
|
|
19
|
+
},
|
|
20
|
+
),
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
export let spec = (doc: Tasks[string]): string =>
|
|
24
|
+
[doc.title, doc.body].filter((v) => v != null).join('\n\n')
|
|
25
|
+
|
|
26
|
+
export let items = (tasks: Tasks): Item[] =>
|
|
27
|
+
Object.entries(tasks).map(([eid, doc]) =>
|
|
28
|
+
message({
|
|
29
|
+
kind: 'instruction',
|
|
30
|
+
text: 'Claimed task ' + eid + '\n' + spec(doc),
|
|
31
|
+
}, 'the system (claimed task specification)')
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
/** The newest admitted task set since this checkpoint, not live graph rows. */
|
|
35
|
+
export let admitted = (entries: Bundle[], checkpoint: Bundle): Tasks => {
|
|
36
|
+
let later = entries.filter((b) =>
|
|
37
|
+
seqOf(b) > seqOf(checkpoint) &&
|
|
38
|
+
(b.task_context as Comp | undefined)?.checkpoint == checkpoint.entity.eid
|
|
39
|
+
).at(-1)
|
|
40
|
+
return ((later?.task_context ?? checkpoint.checkpoint) as Comp)
|
|
41
|
+
.tasks as Tasks ?? {}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** New or edited specs in full, releases as explicit context corrections. */
|
|
45
|
+
export let changes = (before: Tasks, after: Tasks): string =>
|
|
46
|
+
[...new Set([...Object.keys(before), ...Object.keys(after)])].sort()
|
|
47
|
+
.flatMap((eid) =>
|
|
48
|
+
JSON.stringify(before[eid]) == JSON.stringify(after[eid])
|
|
49
|
+
? []
|
|
50
|
+
: after[eid]
|
|
51
|
+
? ['Claimed task ' + eid + '\n' + spec(after[eid])]
|
|
52
|
+
: ['Released task ' + eid + ': no longer claimed by this session.']
|
|
53
|
+
).join('\n\n')
|
package/texted.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// Who hears a text that arrived (@yaks/phone's `text`, read by name). A text
|
|
2
|
+
// back from a number a session texted is that session's, while it can hear,
|
|
3
|
+
// and its project's operator's once it cannot (./watch.ts `targets`), the
|
|
4
|
+
// way a reply to a session's letter is. A text from a number no session
|
|
5
|
+
// texted, or that nobody here wrote to, belongs to the project the number it
|
|
6
|
+
// reached is filed under (@yaks/project's `filed.project` on the entity
|
|
7
|
+
// wearing that `phone{number}`), as a letter to an address filed under a
|
|
8
|
+
// project does. `session_texted` knocks that one target once, named for the
|
|
9
|
+
// text.
|
|
10
|
+
import { line } from "@yaks/query";
|
|
11
|
+
import { derivedEid } from "@yaks/graph/identity";
|
|
12
|
+
import { human } from "@yaks/id";
|
|
13
|
+
import { targets } from "./watch.js";
|
|
14
|
+
let comp = (b, name)=>b?.[name] ?? {};
|
|
15
|
+
let str = (v)=>typeof v == 'string' ? v : '';
|
|
16
|
+
/** The knock a text that arrived owes: none where `eid` is no arrival, it
|
|
17
|
+
* was knocked for already, or nobody here is its reader. */ export let texted = async (g, eid)=>{
|
|
18
|
+
if (!g.vocab.comp('knock') || !g.vocab.comp('text')) return [];
|
|
19
|
+
let [row] = await g.get([
|
|
20
|
+
eid
|
|
21
|
+
]);
|
|
22
|
+
let text = comp(row, 'text');
|
|
23
|
+
let from = str(text.from);
|
|
24
|
+
if (!row || row.deliver || !from) return [];
|
|
25
|
+
let knock = derivedEid(`session texted ${eid}`);
|
|
26
|
+
if ((await g.get([
|
|
27
|
+
knock
|
|
28
|
+
], [
|
|
29
|
+
'knock'
|
|
30
|
+
]))[0]?.knock) return [];
|
|
31
|
+
let [last] = await g.read(line`.text.to=${from}&.delivered&.order=-delivered.at&.limit=1&.fields=created.via`);
|
|
32
|
+
let writer = str(comp(last, 'created').via);
|
|
33
|
+
let [filed] = writer || !g.vocab.prop('filed', 'project') ? [] : await g.read(line`.phone.number=${str(text.to)}&.filed.project&.fields=filed.project`);
|
|
34
|
+
let reader = writer || str(comp(filed, 'filed').project);
|
|
35
|
+
let [to] = reader ? await targets(g, [
|
|
36
|
+
reader
|
|
37
|
+
], new Set()) : [];
|
|
38
|
+
if (!to) return [];
|
|
39
|
+
let [person] = await g.read(line`.phone.number=${from}&.doc&.limit=1&.fields=doc.title`);
|
|
40
|
+
let known = person?.entity.eid;
|
|
41
|
+
let who = str(comp(person, 'doc').title);
|
|
42
|
+
return [
|
|
43
|
+
{
|
|
44
|
+
entity: {
|
|
45
|
+
eid: knock
|
|
46
|
+
},
|
|
47
|
+
knock: {
|
|
48
|
+
target: to,
|
|
49
|
+
...known ? {
|
|
50
|
+
from: known
|
|
51
|
+
} : {}
|
|
52
|
+
},
|
|
53
|
+
doc: {
|
|
54
|
+
body: `text ${human(g.vocab)(row)} from ${who ? `${who} (${from})` : from}: ` + str(comp(row, 'doc').body)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
];
|
|
58
|
+
};
|
|
59
|
+
/** The code behind `session_texted`. */ export let text = async (g, eid)=>{
|
|
60
|
+
let owed = await texted(g, eid);
|
|
61
|
+
if (owed.length) await g.apply(owed, {
|
|
62
|
+
trusted: true
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=texted.js.map
|
package/texted.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"texted.js","sources":["./texted.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,4EAA4E;AAC5E,0EAA0E;AAC1E,wEAAwE;AACxE,6EAA6E;AAC7E,wEAAwE;AACxE,yEAAyE;AACzE,4EAA4E;AAC5E,QAAQ;AAER,SAAS,IAAI,2BAAgC;AAE7C,SAAS,UAAU,oCAAyC;AAC5D,SAAS,KAAK,wBAA6B;AAC3C,SAAS,OAAO,qBAAoB;AAIpC,IAAI,OAAO,CAAC,GAAuB,OAChC,GAAG,CAAC,KAAK,IAAI,CAAC;AACjB,IAAI,MAAM,CAAC,IAAuB,OAAO,KAAK,WAAW,IAAI;AAE7D;0DAC0D,GAC1D,OAAO,IAAI,SAAS,OAAO,GAAM;EAC/B,IAAI,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,SAAS,OAAO,EAAE;EAC9D,IAAI,CAAC,IAAI,GAAG,MAAM,EAAE,GAAG,CAAC;IAAC;GAAI;EAC7B,IAAI,OAAO,KAAK,KAAK;EACrB,IAAI,OAAO,IAAI,KAAK,IAAI;EACxB,IAAI,CAAC,OAAO,IAAI,OAAO,IAAI,CAAC,MAAM,OAAO,EAAE;EAC3C,IAAI,QAAQ,WAAW,CAAC,eAAe,EAAE,KAAK;EAC9C,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC;IAAC;GAAM,EAAE;IAAC;GAAQ,CAAC,CAAC,CAAC,EAAE,EAAE,OAAO,OAAO,EAAE;EAC1D,IAAI,CAAC,KAAK,GAAG,MAAM,EAAE,IAAI,CACvB,IAAI,CAAC,SAAS,EAAE,KAAK,6DAA6D,CAAC;EAErF,IAAI,SAAS,IAAI,KAAK,MAAM,WAAW,GAAG;EAC1C,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,SAAS,aAAa,EAAE,GAAG,MAAM,EAAE,IAAI,CAC3E,IAAI,CAAC,cAAc,EAAE,IAAI,KAAK,EAAE,EAAE,qCAAqC,CAAC;EAE1E,IAAI,SAAS,UAAU,IAAI,KAAK,OAAO,SAAS,OAAO;EACvD,IAAI,CAAC,GAAG,GAAG,SAAS,MAAM,QAAQ,GAAG;IAAC;GAAO,EAAE,IAAI,SAAS,EAAE;EAC9D,IAAI,CAAC,IAAI,OAAO,EAAE;EAClB,IAAI,CAAC,OAAO,GAAG,MAAM,EAAE,IAAI,CACzB,IAAI,CAAC,cAAc,EAAE,KAAK,gCAAgC,CAAC;EAE7D,IAAI,QAAQ,QAAQ,OAAO;EAC3B,IAAI,MAAM,IAAI,KAAK,QAAQ,OAAO,KAAK;EACvC,OAAO;IAAC;MACN,QAAQ;QAAE,KAAK;MAAM;MACrB,OAAO;QAAE,QAAQ;QAAI,GAAG,QAAQ;UAAE,MAAM;QAAM,IAAI,CAAC,CAAC;MAAC;MACrD,KAAK;QACH,MACE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,MAAM,EAChC,MAAM,GAAG,IAAI,EAAE,EAAE,KAAK,CAAC,CAAC,GAAG,KAC5B,EAAE,CAAC,GACJ,IAAI,KAAK,KAAK,OAAO,IAAI;MAC7B;IACF;GAAE;AACJ,EAAC;AAED,sCAAsC,GACtC,OAAO,IAAI,OAAO,OAAO,GAAM;EAC7B,IAAI,OAAO,MAAM,OAAO,GAAG;EAC3B,IAAI,KAAK,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM;IAAE,SAAS;EAAK;AACvD,EAAC"}
|
package/texted.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// Who hears a text that arrived (@yaks/phone's `text`, read by name). A text
|
|
2
|
+
// back from a number a session texted is that session's, while it can hear,
|
|
3
|
+
// and its project's operator's once it cannot (./watch.ts `targets`), the
|
|
4
|
+
// way a reply to a session's letter is. A text from a number no session
|
|
5
|
+
// texted, or that nobody here wrote to, belongs to the project the number it
|
|
6
|
+
// reached is filed under (@yaks/project's `filed.project` on the entity
|
|
7
|
+
// wearing that `phone{number}`), as a letter to an address filed under a
|
|
8
|
+
// project does. `session_texted` knocks that one target once, named for the
|
|
9
|
+
// text.
|
|
10
|
+
|
|
11
|
+
import { line } from '@yaks/query'
|
|
12
|
+
import type { Bundle, Comp, Eid, Graph } from 'jsr:@yaks/graph@0.2.36'
|
|
13
|
+
import { derivedEid } from '@yaks/graph/identity'
|
|
14
|
+
import { human } from '@yaks/id'
|
|
15
|
+
import { targets } from './watch.js'
|
|
16
|
+
|
|
17
|
+
type G = Pick<Graph, 'vocab' | 'read' | 'get' | 'apply'>
|
|
18
|
+
|
|
19
|
+
let comp = (b: Bundle | undefined, name: string): Comp =>
|
|
20
|
+
(b?.[name] ?? {}) as Comp
|
|
21
|
+
let str = (v: unknown): string => typeof v == 'string' ? v : ''
|
|
22
|
+
|
|
23
|
+
/** The knock a text that arrived owes: none where `eid` is no arrival, it
|
|
24
|
+
* was knocked for already, or nobody here is its reader. */
|
|
25
|
+
export let texted = async (g: G, eid: Eid): Promise<Bundle[]> => {
|
|
26
|
+
if (!g.vocab.comp('knock') || !g.vocab.comp('text')) return []
|
|
27
|
+
let [row] = await g.get([eid])
|
|
28
|
+
let text = comp(row, 'text')
|
|
29
|
+
let from = str(text.from)
|
|
30
|
+
if (!row || row.deliver || !from) return []
|
|
31
|
+
let knock = derivedEid(`session texted ${eid}`)
|
|
32
|
+
if ((await g.get([knock], ['knock']))[0]?.knock) return []
|
|
33
|
+
let [last] = await g.read(
|
|
34
|
+
line`.text.to=${from}&.delivered&.order=-delivered.at&.limit=1&.fields=created.via`,
|
|
35
|
+
)
|
|
36
|
+
let writer = str(comp(last, 'created').via)
|
|
37
|
+
let [filed] = writer || !g.vocab.prop('filed', 'project') ? [] : await g.read(
|
|
38
|
+
line`.phone.number=${str(text.to)}&.filed.project&.fields=filed.project`,
|
|
39
|
+
)
|
|
40
|
+
let reader = writer || str(comp(filed, 'filed').project)
|
|
41
|
+
let [to] = reader ? await targets(g, [reader], new Set()) : []
|
|
42
|
+
if (!to) return []
|
|
43
|
+
let [person] = await g.read(
|
|
44
|
+
line`.phone.number=${from}&.doc&.limit=1&.fields=doc.title`,
|
|
45
|
+
)
|
|
46
|
+
let known = person?.entity.eid
|
|
47
|
+
let who = str(comp(person, 'doc').title)
|
|
48
|
+
return [{
|
|
49
|
+
entity: { eid: knock },
|
|
50
|
+
knock: { target: to, ...known ? { from: known } : {} },
|
|
51
|
+
doc: {
|
|
52
|
+
body:
|
|
53
|
+
`text ${human(g.vocab)(row)} from ${
|
|
54
|
+
who ? `${who} (${from})` : from
|
|
55
|
+
}: ` +
|
|
56
|
+
str(comp(row, 'doc').body),
|
|
57
|
+
},
|
|
58
|
+
}]
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** The code behind `session_texted`. */
|
|
62
|
+
export let text = async (g: G, eid: Eid): Promise<void> => {
|
|
63
|
+
let owed = await texted(g, eid)
|
|
64
|
+
if (owed.length) await g.apply(owed, { trusted: true })
|
|
65
|
+
}
|
package/timing.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** Human-readable wall-clock duration, retaining sub-second precision. */ export let duration = (ms)=>{
|
|
2
|
+
ms = Math.max(0, Math.round(ms));
|
|
3
|
+
if (ms < 1000) return `${ms}ms`;
|
|
4
|
+
let seconds = Math.floor(ms / 1000);
|
|
5
|
+
return seconds < 60 ? `${seconds}s` : `${Math.floor(seconds / 60)}m${seconds % 60}s`;
|
|
6
|
+
};
|
|
7
|
+
/** Timing is appended after bounded output, never inside a truncation window. */ export let took = (text, ms)=>`${text}${text ? '\n' : ''}took ${duration(ms)}` + (ms > 60_000 ? ' — over 60s: report this slow command' : '');
|
|
8
|
+
/** Sum of measured tool waits (parallel calls add, not session age). Older
|
|
9
|
+
* unmeasured results are omitted rather than invented from queue timestamps. */ export let toolTiming = (rows)=>{
|
|
10
|
+
let byId = new Map(rows.map((r)=>[
|
|
11
|
+
r.eid,
|
|
12
|
+
r
|
|
13
|
+
]));
|
|
14
|
+
let seen = new Set();
|
|
15
|
+
let runs = rows.flatMap((r)=>{
|
|
16
|
+
let call = String(r.comps.result?.call ?? '');
|
|
17
|
+
let ms = r.comps.result?.ms;
|
|
18
|
+
if (!call || seen.has(call) || typeof ms != 'number' || !Number.isFinite(ms) || ms < 0) return [];
|
|
19
|
+
seen.add(call);
|
|
20
|
+
let c = byId.get(call)?.comps;
|
|
21
|
+
let args = c?.call?.args ?? {};
|
|
22
|
+
let label = String(c?.bash?.command ?? args.command ?? c?.tool?.name ?? c?.call?.to ?? 'tool');
|
|
23
|
+
return [
|
|
24
|
+
{
|
|
25
|
+
ms,
|
|
26
|
+
label: label.replace(/\s+/g, ' ').slice(0, 200)
|
|
27
|
+
}
|
|
28
|
+
];
|
|
29
|
+
});
|
|
30
|
+
if (!runs.length) return '';
|
|
31
|
+
return [
|
|
32
|
+
`Tool wall-clock: ${duration(runs.reduce((sum, r)=>sum + r.ms, 0))} (sum of ${runs.length} measured calls; parallel waits add).`,
|
|
33
|
+
'Slowest commands/tools:',
|
|
34
|
+
...runs.toSorted((a, b)=>b.ms - a.ms).slice(0, 3).map((r)=>`- ${duration(r.ms)} — ${r.label}`)
|
|
35
|
+
].join('\n');
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=timing.js.map
|
package/timing.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timing.js","sources":["./timing.ts"],"names":[],"mappings":"AAAA,wEAAwE,GACxE,OAAO,IAAI,WAAW,CAAC;EACrB,KAAK,KAAK,GAAG,CAAC,GAAG,KAAK,KAAK,CAAC;EAC5B,IAAI,KAAK,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC;EAC/B,IAAI,UAAU,KAAK,KAAK,CAAC,KAAK;EAC9B,OAAO,UAAU,KACb,GAAG,QAAQ,CAAC,CAAC,GACb,GAAG,KAAK,KAAK,CAAC,UAAU,IAAI,CAAC,EAAE,UAAU,GAAG,CAAC,CAAC;AACpD,EAAC;AAED,+EAA+E,GAC/E,OAAO,IAAI,OAAO,CAAC,MAAc,KAC/B,GAAG,OAAO,OAAO,OAAO,GAAG,KAAK,EAAE,SAAS,KAAK,GAChD,CAAC,KAAK,SAAS,0CAA0C,EAAE,EAAC;AAO9D;8EAC8E,GAC9E,OAAO,IAAI,aAAa,CAAC;EACvB,IAAI,OAAO,IAAI,IAAI,KAAK,GAAG,CAAC,CAAC,IAAM;MAAC,EAAE,GAAG;MAAE;KAAE;EAC7C,IAAI,OAAO,IAAI;EACf,IAAI,OAAO,KAAK,OAAO,CAAC,CAAC;IACvB,IAAI,OAAO,OAAO,EAAE,KAAK,CAAC,MAAM,EAAE,QAAQ;IAC1C,IAAI,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE;IACzB,IACE,CAAC,QAAQ,KAAK,GAAG,CAAC,SAAS,OAAO,MAAM,YACxC,CAAC,OAAO,QAAQ,CAAC,OAAO,KAAK,GAC7B,OAAO,EAAE;IACX,KAAK,GAAG,CAAC;IACT,IAAI,IAAI,KAAK,GAAG,CAAC,OAAO;IACxB,IAAI,OAAQ,GAAG,MAAM,QAAQ,CAAC;IAC9B,IAAI,QAAQ,OACV,GAAG,MAAM,WAAW,KAAK,OAAO,IAAI,GAAG,MAAM,QAAQ,GAAG,MAAM,MAC5D;IAEJ,OAAO;MAAC;QAAE;QAAI,OAAO,MAAM,OAAO,CAAC,QAAQ,KAAK,KAAK,CAAC,GAAG;MAAK;KAAE;EAClE;EACA,IAAI,CAAC,KAAK,MAAM,EAAE,OAAO;EACzB,OAAO;IACL,CAAC,iBAAiB,EAChB,SAAS,KAAK,MAAM,CAAC,CAAC,KAAK,IAAM,MAAM,EAAE,EAAE,EAAE,IAC9C,SAAS,EAAE,KAAK,MAAM,CAAC,qCAAqC,CAAC;IAC9D;OACG,KAAK,QAAQ,CAAC,CAAC,GAAG,IAAM,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,KAAK,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,IACvD,CAAC,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE;GAErC,CAAC,IAAI,CAAC;AACT,EAAC"}
|
package/timing.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/** Human-readable wall-clock duration, retaining sub-second precision. */
|
|
2
|
+
export let duration = (ms: number): string => {
|
|
3
|
+
ms = Math.max(0, Math.round(ms))
|
|
4
|
+
if (ms < 1000) return `${ms}ms`
|
|
5
|
+
let seconds = Math.floor(ms / 1000)
|
|
6
|
+
return seconds < 60
|
|
7
|
+
? `${seconds}s`
|
|
8
|
+
: `${Math.floor(seconds / 60)}m${seconds % 60}s`
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** Timing is appended after bounded output, never inside a truncation window. */
|
|
12
|
+
export let took = (text: string, ms: number): string =>
|
|
13
|
+
`${text}${text ? '\n' : ''}took ${duration(ms)}` +
|
|
14
|
+
(ms > 60_000 ? ' — over 60s: report this slow command' : '')
|
|
15
|
+
|
|
16
|
+
type TimingRow = {
|
|
17
|
+
eid: string
|
|
18
|
+
comps: Record<string, Record<string, unknown> | undefined>
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Sum of measured tool waits (parallel calls add, not session age). Older
|
|
22
|
+
* unmeasured results are omitted rather than invented from queue timestamps. */
|
|
23
|
+
export let toolTiming = (rows: TimingRow[]): string => {
|
|
24
|
+
let byId = new Map(rows.map((r) => [r.eid, r]))
|
|
25
|
+
let seen = new Set<string>()
|
|
26
|
+
let runs = rows.flatMap((r) => {
|
|
27
|
+
let call = String(r.comps.result?.call ?? '')
|
|
28
|
+
let ms = r.comps.result?.ms
|
|
29
|
+
if (
|
|
30
|
+
!call || seen.has(call) || typeof ms != 'number' ||
|
|
31
|
+
!Number.isFinite(ms) || ms < 0
|
|
32
|
+
) return []
|
|
33
|
+
seen.add(call)
|
|
34
|
+
let c = byId.get(call)?.comps
|
|
35
|
+
let args = (c?.call?.args ?? {}) as Record<string, unknown>
|
|
36
|
+
let label = String(
|
|
37
|
+
c?.bash?.command ?? args.command ?? c?.tool?.name ?? c?.call?.to ??
|
|
38
|
+
'tool',
|
|
39
|
+
)
|
|
40
|
+
return [{ ms, label: label.replace(/\s+/g, ' ').slice(0, 200) }]
|
|
41
|
+
})
|
|
42
|
+
if (!runs.length) return ''
|
|
43
|
+
return [
|
|
44
|
+
`Tool wall-clock: ${
|
|
45
|
+
duration(runs.reduce((sum, r) => sum + r.ms, 0))
|
|
46
|
+
} (sum of ${runs.length} measured calls; parallel waits add).`,
|
|
47
|
+
'Slowest commands/tools:',
|
|
48
|
+
...runs.toSorted((a, b) => b.ms - a.ms).slice(0, 3).map((r) =>
|
|
49
|
+
`- ${duration(r.ms)} — ${r.label}`
|
|
50
|
+
),
|
|
51
|
+
].join('\n')
|
|
52
|
+
}
|
package/told.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// The instructions an ask sent, kept once per distinct text: a
|
|
2
|
+
// `told{instructions}` row whose eid is their sha256, named by the ask as
|
|
3
|
+
// `sending{told}`, the way `offer{tools}` keeps the tools it sent. Asks
|
|
4
|
+
// repeat the same tens of kilobytes from one turn to the next, so an ask
|
|
5
|
+
// holds a name and the text is stored once.
|
|
6
|
+
//
|
|
7
|
+
// An input still selects instructions as text (`sending{instructions}`); a
|
|
8
|
+
// reader of what is in force takes either through {@link instructionsOf}.
|
|
9
|
+
import { sha256 } from "@yaks/graph/sha256";
|
|
10
|
+
/** The `told` row holding `instructions`, named by their sha256.
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { assertEquals } from '@std/assert'
|
|
14
|
+
* import { sha256 } from '@yaks/graph/sha256'
|
|
15
|
+
* assertEquals(toldRow('Be brief.'), {
|
|
16
|
+
* entity: { eid: sha256('Be brief.') },
|
|
17
|
+
* told: { instructions: 'Be brief.' },
|
|
18
|
+
* })
|
|
19
|
+
* ```
|
|
20
|
+
*/ export let toldRow = (instructions)=>({
|
|
21
|
+
entity: {
|
|
22
|
+
eid: sha256(instructions)
|
|
23
|
+
},
|
|
24
|
+
told: {
|
|
25
|
+
instructions
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
/** The instructions a `sending` says: the text an input selected, or the
|
|
29
|
+
* text of the `told` row an ask names. Undefined where it says none. */ export let instructionsOf = async (g, sending)=>{
|
|
30
|
+
if (typeof sending?.instructions == 'string') return sending.instructions;
|
|
31
|
+
let told = sending?.told;
|
|
32
|
+
if (typeof told != 'string') return undefined;
|
|
33
|
+
return (await toldOf(g, [
|
|
34
|
+
told
|
|
35
|
+
])).get(told);
|
|
36
|
+
};
|
|
37
|
+
/** The texts of the `told` rows named, by their eid; a name with no row is
|
|
38
|
+
* left out. */ export let toldOf = async (g, names)=>{
|
|
39
|
+
let wanted = [
|
|
40
|
+
...new Set(names)
|
|
41
|
+
];
|
|
42
|
+
if (!wanted.length) return new Map();
|
|
43
|
+
let rows = await g.get(wanted, [
|
|
44
|
+
'told'
|
|
45
|
+
]);
|
|
46
|
+
return new Map(rows.flatMap((b)=>{
|
|
47
|
+
let text = b?.told?.instructions;
|
|
48
|
+
return typeof text == 'string' ? [
|
|
49
|
+
[
|
|
50
|
+
b.entity.eid,
|
|
51
|
+
text
|
|
52
|
+
]
|
|
53
|
+
] : [];
|
|
54
|
+
}));
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=told.js.map
|
package/told.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"told.js","sources":["./told.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,0EAA0E;AAC1E,wEAAwE;AACxE,yEAAyE;AACzE,4CAA4C;AAC5C,EAAE;AACF,2EAA2E;AAC3E,0EAA0E;AAG1E,SAAS,MAAM,kCAAuC;AAEtD;;;;;;;;;;CAUC,GACD,OAAO,IAAI,UAAU,CAAC,eAAiC,CAAC;IACtD,QAAQ;MAAE,KAAK,OAAO;IAAc;IACpC,MAAM;MAAE;IAAa;EACvB,CAAC,EAAC;AAEF;sEACsE,GACtE,OAAO,IAAI,iBAAiB,OAC1B,GACA;EAEA,IAAI,OAAO,SAAS,gBAAgB,UAAU,OAAO,QAAQ,YAAY;EACzE,IAAI,OAAO,SAAS;EACpB,IAAI,OAAO,QAAQ,UAAU,OAAO;EACpC,OAAO,CAAC,MAAM,OAAO,GAAG;IAAC;GAAK,CAAC,EAAE,GAAG,CAAC;AACvC,EAAC;AAED;aACa,GACb,OAAO,IAAI,SAAS,OAClB,GACA;EAEA,IAAI,SAAS;OAAI,IAAI,IAAI;GAAO;EAChC,IAAI,CAAC,OAAO,MAAM,EAAE,OAAO,IAAI;EAC/B,IAAI,OAAO,MAAM,EAAE,GAAG,CAAC,QAAQ;IAAC;GAAO;EACvC,OAAO,IAAI,IAAI,KAAK,OAAO,CAAC,CAAC;IAC3B,IAAI,OAAQ,GAAG,MAA2B;IAC1C,OAAO,OAAO,QAAQ,WAAW;MAAC;QAAC,EAAE,MAAM,CAAC,GAAG;QAAE;OAAK;KAAC,GAAG,EAAE;EAC9D;AACF,EAAC"}
|
package/told.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// The instructions an ask sent, kept once per distinct text: a
|
|
2
|
+
// `told{instructions}` row whose eid is their sha256, named by the ask as
|
|
3
|
+
// `sending{told}`, the way `offer{tools}` keeps the tools it sent. Asks
|
|
4
|
+
// repeat the same tens of kilobytes from one turn to the next, so an ask
|
|
5
|
+
// holds a name and the text is stored once.
|
|
6
|
+
//
|
|
7
|
+
// An input still selects instructions as text (`sending{instructions}`); a
|
|
8
|
+
// reader of what is in force takes either through {@link instructionsOf}.
|
|
9
|
+
|
|
10
|
+
import type { Bundle, Comp, Graph } from 'jsr:@yaks/graph@0.2.36'
|
|
11
|
+
import { sha256 } from '@yaks/graph/sha256'
|
|
12
|
+
|
|
13
|
+
/** The `told` row holding `instructions`, named by their sha256.
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* import { assertEquals } from '@std/assert'
|
|
17
|
+
* import { sha256 } from '@yaks/graph/sha256'
|
|
18
|
+
* assertEquals(toldRow('Be brief.'), {
|
|
19
|
+
* entity: { eid: sha256('Be brief.') },
|
|
20
|
+
* told: { instructions: 'Be brief.' },
|
|
21
|
+
* })
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export let toldRow = (instructions: string): Bundle => ({
|
|
25
|
+
entity: { eid: sha256(instructions) },
|
|
26
|
+
told: { instructions },
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
/** The instructions a `sending` says: the text an input selected, or the
|
|
30
|
+
* text of the `told` row an ask names. Undefined where it says none. */
|
|
31
|
+
export let instructionsOf = async (
|
|
32
|
+
g: Pick<Graph, 'get'>,
|
|
33
|
+
sending: Comp | undefined,
|
|
34
|
+
): Promise<string | undefined> => {
|
|
35
|
+
if (typeof sending?.instructions == 'string') return sending.instructions
|
|
36
|
+
let told = sending?.told
|
|
37
|
+
if (typeof told != 'string') return undefined
|
|
38
|
+
return (await toldOf(g, [told])).get(told)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** The texts of the `told` rows named, by their eid; a name with no row is
|
|
42
|
+
* left out. */
|
|
43
|
+
export let toldOf = async (
|
|
44
|
+
g: Pick<Graph, 'get'>,
|
|
45
|
+
names: Iterable<string>,
|
|
46
|
+
): Promise<Map<string, string>> => {
|
|
47
|
+
let wanted = [...new Set(names)]
|
|
48
|
+
if (!wanted.length) return new Map()
|
|
49
|
+
let rows = await g.get(wanted, ['told'])
|
|
50
|
+
return new Map(rows.flatMap((b) => {
|
|
51
|
+
let text = (b?.told as Comp | undefined)?.instructions
|
|
52
|
+
return typeof text == 'string' ? [[b.entity.eid, text]] : []
|
|
53
|
+
}))
|
|
54
|
+
}
|