@dynamicagents/plugins 0.12.0 → 0.14.0

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.
Files changed (132) hide show
  1. package/README.md +58 -77
  2. package/dist/browser/index.d.ts +0 -2
  3. package/dist/browser/index.js +21 -27
  4. package/dist/claude-code/cards.d.ts +55 -0
  5. package/dist/claude-code/cards.js +283 -0
  6. package/dist/claude-code/config.d.ts +28 -63
  7. package/dist/claude-code/config.js +0 -11
  8. package/dist/claude-code/egress.d.ts +8 -1
  9. package/dist/claude-code/egress.js +42 -4
  10. package/dist/claude-code/events.d.ts +106 -9
  11. package/dist/claude-code/events.js +201 -56
  12. package/dist/claude-code/github.d.ts +39 -0
  13. package/dist/claude-code/github.js +82 -0
  14. package/dist/claude-code/index.d.ts +16 -90
  15. package/dist/claude-code/index.js +14 -276
  16. package/dist/claude-code/model.d.ts +152 -0
  17. package/dist/claude-code/model.js +366 -0
  18. package/dist/claude-code/run.d.ts +230 -116
  19. package/dist/claude-code/run.js +380 -167
  20. package/dist/claude-code/session.d.ts +131 -0
  21. package/dist/claude-code/session.js +288 -0
  22. package/dist/claude-code/spec.d.ts +46 -0
  23. package/dist/claude-code/spec.js +83 -0
  24. package/dist/claude-code/verified.d.ts +15 -0
  25. package/dist/claude-code/verified.js +15 -0
  26. package/dist/computer/context.d.ts +1 -5
  27. package/dist/computer/context.js +7 -10
  28. package/dist/computer/file-lock.js +5 -4
  29. package/dist/computer/gate.d.ts +4 -4
  30. package/dist/computer/gate.js +5 -5
  31. package/dist/computer/index.d.ts +40 -258
  32. package/dist/computer/index.js +71 -324
  33. package/dist/computer/paths.d.ts +36 -16
  34. package/dist/computer/paths.js +42 -29
  35. package/dist/computer/proxy.d.ts +45 -0
  36. package/dist/computer/proxy.js +234 -0
  37. package/dist/computer/render.d.ts +1 -40
  38. package/dist/computer/render.js +2 -68
  39. package/dist/computer/tools-exec.js +12 -13
  40. package/dist/computer/tools-file.d.ts +9 -1
  41. package/dist/computer/tools-file.js +22 -82
  42. package/dist/computer/{tools-find.d.ts → tools-grep.d.ts} +1 -1
  43. package/dist/computer/tools-grep.js +129 -0
  44. package/dist/repo/checkout.d.ts +4 -5
  45. package/dist/repo/checkout.js +31 -8
  46. package/dist/repo/context.d.ts +35 -9
  47. package/dist/repo/context.js +101 -49
  48. package/dist/repo/index.d.ts +73 -28
  49. package/dist/repo/index.js +112 -96
  50. package/dist/repo/tools-checks.d.ts +3 -0
  51. package/dist/repo/tools-checks.js +112 -0
  52. package/dist/repo/tools-clone.js +1 -1
  53. package/dist/repo/tools-pr.d.ts +14 -0
  54. package/dist/repo/{tools-forge.js → tools-pr.js} +53 -36
  55. package/dist/repo/tools-review.d.ts +9 -0
  56. package/dist/repo/tools-review.js +67 -47
  57. package/dist/repo/tools-worktree.js +144 -60
  58. package/dist/repo/tools-worktrees.d.ts +12 -0
  59. package/dist/repo/tools-worktrees.js +48 -0
  60. package/dist/repo/url.d.ts +2 -2
  61. package/dist/repo/url.js +7 -7
  62. package/dist/scratch/index.d.ts +4 -4
  63. package/dist/scratch/index.js +12 -11
  64. package/dist/{computer → workspace}/advisory.d.ts +4 -4
  65. package/dist/{computer → workspace}/advisory.js +2 -2
  66. package/dist/{computer/host → workspace}/ca-trust.d.ts +8 -1
  67. package/dist/{computer/host → workspace}/ca-trust.js +12 -3
  68. package/dist/{computer/host → workspace}/container-deps.d.ts +4 -0
  69. package/dist/{computer/host → workspace}/container-deps.js +26 -1
  70. package/dist/{computer/host → workspace}/container-fault.d.ts +3 -3
  71. package/dist/{computer/host → workspace}/container-fault.js +23 -8
  72. package/dist/workspace/deps-snapshot.d.ts +110 -0
  73. package/dist/workspace/deps-snapshot.js +424 -0
  74. package/dist/workspace/exec.d.ts +94 -0
  75. package/dist/workspace/exec.js +153 -0
  76. package/dist/workspace/format.d.ts +36 -0
  77. package/dist/workspace/format.js +57 -0
  78. package/dist/{computer/host → workspace}/git-host.d.ts +21 -4
  79. package/dist/{computer/host → workspace}/git-host.js +72 -2
  80. package/dist/{computer/host → workspace}/git-identity.d.ts +1 -1
  81. package/dist/{computer/host → workspace}/git-identity.js +1 -1
  82. package/dist/workspace/index.d.ts +44 -47
  83. package/dist/workspace/index.js +52 -112
  84. package/dist/{computer/host → workspace}/install-job.d.ts +53 -4
  85. package/dist/{computer/host → workspace}/install-job.js +346 -178
  86. package/dist/{computer → workspace}/install.d.ts +17 -8
  87. package/dist/{computer → workspace}/install.js +24 -6
  88. package/dist/{computer/host/workspace.d.ts → workspace/object.d.ts} +125 -27
  89. package/dist/{computer/host/workspace.js → workspace/object.js} +341 -58
  90. package/dist/workspace/open.d.ts +95 -0
  91. package/dist/workspace/open.js +63 -0
  92. package/dist/workspace/read.d.ts +16 -0
  93. package/dist/workspace/read.js +22 -0
  94. package/dist/{computer → workspace}/shell.d.ts +5 -5
  95. package/dist/{computer → workspace}/shell.js +6 -6
  96. package/dist/{computer/host → workspace}/wake.d.ts +3 -1
  97. package/package.json +17 -37
  98. package/dist/arc-agi/analysis.d.ts +0 -322
  99. package/dist/arc-agi/analysis.js +0 -802
  100. package/dist/arc-agi/client.d.ts +0 -82
  101. package/dist/arc-agi/client.js +0 -113
  102. package/dist/arc-agi/game-tools.d.ts +0 -24
  103. package/dist/arc-agi/game-tools.js +0 -26
  104. package/dist/arc-agi/index.d.ts +0 -40
  105. package/dist/arc-agi/index.js +0 -175
  106. package/dist/arc-agi/main-agent.d.ts +0 -24
  107. package/dist/arc-agi/main-agent.js +0 -62
  108. package/dist/arc-agi/recipe.d.ts +0 -48
  109. package/dist/arc-agi/recipe.js +0 -97
  110. package/dist/arc-agi/scorecard.d.ts +0 -118
  111. package/dist/arc-agi/scorecard.js +0 -163
  112. package/dist/arc-agi/soul.d.ts +0 -29
  113. package/dist/arc-agi/soul.js +0 -79
  114. package/dist/arc-agi/store.d.ts +0 -153
  115. package/dist/arc-agi/store.js +0 -215
  116. package/dist/arc-agi/tools.d.ts +0 -36
  117. package/dist/arc-agi/tools.js +0 -574
  118. package/dist/arc-agi/types.d.ts +0 -211
  119. package/dist/arc-agi/types.js +0 -19
  120. package/dist/claude-code/recipe.d.ts +0 -53
  121. package/dist/claude-code/recipe.js +0 -100
  122. package/dist/computer/read.d.ts +0 -133
  123. package/dist/computer/read.js +0 -200
  124. package/dist/computer/tools-find.js +0 -216
  125. package/dist/recall/index.d.ts +0 -105
  126. package/dist/recall/index.js +0 -181
  127. package/dist/repo/tools-forge.d.ts +0 -4
  128. package/dist/triage/index.d.ts +0 -360
  129. package/dist/triage/index.js +0 -311
  130. /package/dist/{computer/host → workspace}/sync.d.ts +0 -0
  131. /package/dist/{computer/host → workspace}/sync.js +0 -0
  132. /package/dist/{computer/host → workspace}/wake.js +0 -0
@@ -1,215 +0,0 @@
1
- import { desc, eq, gte, lt } from "drizzle-orm";
2
- import { drizzle } from "drizzle-orm/durable-sqlite";
3
- import { index, integer, sqliteTable, text } from "drizzle-orm/sqlite-core";
4
- import { z } from "zod";
5
- /**
6
- * The `arc_scorecards` table — cards this agent opened, as a **recency ledger**
7
- * rather than a lifecycle.
8
- *
9
- * The ARC API auto-closes a card after ~15 minutes idle, so nothing here ever
10
- * closes one and there is no open/closed state worth keeping: a card used
11
- * recently is live, an older one is gone. `last_used_at` is that clock, bumped
12
- * every time a play resolves onto the card, and the only column anything queries
13
- * by — see `resolveScorecard` in {@link file://./scorecard.ts}.
14
- *
15
- * ## Why the DDL is hand-written and the queries are not
16
- *
17
- * A plugin must never run drizzle's durable-sqlite **migrator**: it keeps one
18
- * flat integer journal and one global `__drizzle_migrations` table, which two
19
- * independently-versioned packages cannot share: two agents consuming the same
20
- * module fork that journal at the first index they disagree on. And
21
- * `drizzle-kit generate` diffs against a snapshot in a single output directory,
22
- * so a plugin shipping from its own repo cannot produce a correct diff at all.
23
- *
24
- * None of that touches the **query builder**, which is a typed wrapper over the
25
- * same `DurableObjectStorage` holding no journal and no connection state. So the
26
- * split is: `CREATE TABLE IF NOT EXISTS` by hand in {@link arcScorecardStore},
27
- * every read and write through drizzle below. A second handle alongside core's
28
- * `AgentDB` is safe — neither carries state the other can disturb.
29
- *
30
- * The table is prefixed `arc_` because a plugin's tables share one SQLite
31
- * database with core's and with every other installed plugin's. An unprefixed
32
- * `scorecards` is a name a second plugin could plausibly want.
33
- */
34
- export const arcScorecards = sqliteTable("arc_scorecards", {
35
- /** The ARC-assigned card id (a uuid). */
36
- cardId: text("card_id").primaryKey(),
37
- /**
38
- * JSON cookie jar from `POST /api/scorecard/open`. The ARC API pins a card to
39
- * the session that opened it: without these cookies the card is invisible —
40
- * RESET reports the game as not found — so the jar is part of the card's
41
- * identity, not an optimization.
42
- */
43
- cookiesJson: text("cookies_json").notNull().default("{}"),
44
- /**
45
- * JSON `{ [gameId]: guid }` — the play this card already opened per game.
46
- *
47
- * This is what makes RESET happen **once per game per card**. A guid is the
48
- * only handle the ARC API gives to a play, and it is mintable only by RESET,
49
- * so a second RESET is a second play: a new run on the card, scored
50
- * separately, discarding whatever the first reached. Recording the guid here
51
- * means a re-dispatched Subtask or a subagent that lost its workspace resumes
52
- * the play this card already has instead of starting another one.
53
- */
54
- guidsJson: text("guids_json").notNull().default("{}"),
55
- openedAt: integer("opened_at").notNull(),
56
- /** Last time a play resolved onto this card — the reuse clock. */
57
- lastUsedAt: integer("last_used_at").notNull()
58
- }, (table) => [index("idx_arc_scorecards_last_used_at").on(table.lastUsedAt)]);
59
- /** The DDL, matching the declaration above. Idempotent; re-run on every wake-up. */
60
- const DDL = [
61
- `CREATE TABLE IF NOT EXISTS arc_scorecards (
62
- card_id TEXT PRIMARY KEY NOT NULL,
63
- cookies_json TEXT NOT NULL DEFAULT '{}',
64
- guids_json TEXT NOT NULL DEFAULT '{}',
65
- opened_at INTEGER NOT NULL,
66
- last_used_at INTEGER NOT NULL
67
- )`,
68
- `CREATE INDEX IF NOT EXISTS idx_arc_scorecards_last_used_at
69
- ON arc_scorecards (last_used_at)`
70
- ];
71
- /** How long a scorecard row is kept before a maintenance sweep removes it. */
72
- export const SCORECARD_RETENTION_MS = 30 * 24 * 60 * 60 * 1000;
73
- const cookiesSchema = z.record(z.string(), z.string());
74
- const guidsSchema = z.record(z.string(), z.string());
75
- /**
76
- * This plugin's `PluginStore` — the DDL half, handed to `new AgentDB(storage,
77
- * { stores })` by the host through `runtime.stores`.
78
- *
79
- * `version` bumps whenever {@link PluginStore.ensureTables} needs to do
80
- * something it did not do before; `from` is the version last recorded on disk,
81
- * so an upgrade path branches on it without re-running earlier DDL.
82
- */
83
- export const arcScorecardStore = {
84
- plugin: "arc-agi",
85
- version: 1,
86
- ensureTables(sql) {
87
- for (const statement of DDL)
88
- sql.exec(statement);
89
- }
90
- };
91
- /**
92
- * Query methods for `arc_scorecards`, over the plugin's **own** drizzle handle.
93
- *
94
- * durable-sqlite is synchronous, so these return plain values. The narrow
95
- * {@link ScorecardStore} port is what `resolveScorecard`/`resolvePlay` consume,
96
- * so a spec can pass an in-memory fake and never touch SQLite at all.
97
- */
98
- export function makeScorecardStore(storage) {
99
- const db = drizzle(storage, { schema: { arcScorecards } });
100
- const rowToScorecard = (row) => ({
101
- cardId: row.cardId,
102
- cookies: cookiesSchema.parse(JSON.parse(row.cookiesJson)),
103
- guids: guidsSchema.parse(JSON.parse(row.guidsJson)),
104
- openedAt: row.openedAt,
105
- lastUsedAt: row.lastUsedAt
106
- });
107
- return {
108
- /**
109
- * Record a freshly opened card together with the cookie jar the open call
110
- * returned. The jar is not optional bookkeeping: the ARC API pins the card to
111
- * that session, so a row without it names a card nobody can reach.
112
- */
113
- open(cardId, cookies) {
114
- const now = Date.now();
115
- const row = db
116
- .insert(arcScorecards)
117
- .values({
118
- cardId,
119
- cookiesJson: JSON.stringify(cookies),
120
- openedAt: now,
121
- lastUsedAt: now
122
- })
123
- .returning()
124
- .get();
125
- return rowToScorecard(row);
126
- },
127
- /** Load one card by id. */
128
- get(cardId) {
129
- const row = db
130
- .select()
131
- .from(arcScorecards)
132
- .where(eq(arcScorecards.cardId, cardId))
133
- .get();
134
- return row ? rowToScorecard(row) : null;
135
- },
136
- /**
137
- * The most recently used card still inside the caller's reuse window, or null
138
- * if every card is older than `since`. The single read the resolution path
139
- * makes — see `resolveScorecard` in {@link file://./scorecard.ts}, which owns
140
- * the window itself.
141
- */
142
- findRecent(since) {
143
- const row = db
144
- .select()
145
- .from(arcScorecards)
146
- .where(gte(arcScorecards.lastUsedAt, since))
147
- .orderBy(desc(arcScorecards.lastUsedAt))
148
- .get();
149
- return row ? rowToScorecard(row) : null;
150
- },
151
- /**
152
- * Record the guid a RESET minted for one game on one card, so the next
153
- * resolution of that game rejoins the play instead of opening another.
154
- *
155
- * Read-modify-write of a JSON map rather than a `(card_id, game_id)` table:
156
- * durable-sqlite is synchronous and single-threaded within the DO, so this
157
- * cannot interleave, and every reader already loads the whole row.
158
- *
159
- * First writer wins. Two concurrent resolutions of the same game can both
160
- * find no guid and both RESET, and the loser's play must not overwrite the
161
- * guid the winner already handed out — keeping the first keeps everyone
162
- * afterwards on one play.
163
- */
164
- setGuid(cardId, gameId, guid) {
165
- const row = db
166
- .select()
167
- .from(arcScorecards)
168
- .where(eq(arcScorecards.cardId, cardId))
169
- .get();
170
- if (!row)
171
- return;
172
- const guids = guidsSchema.parse(JSON.parse(row.guidsJson));
173
- if (guids[gameId] !== undefined)
174
- return;
175
- db.update(arcScorecards)
176
- .set({ guidsJson: JSON.stringify({ ...guids, [gameId]: guid }) })
177
- .where(eq(arcScorecards.cardId, cardId))
178
- .run();
179
- },
180
- /**
181
- * Restart a card's reuse clock. Called once per durable chunk of every play
182
- * running on the card, which is what keeps a long play's card alive: chunks
183
- * are bounded well under the window (see core's `CHUNK_SOFT_MS`), so an
184
- * active card is always re-touched before it can expire.
185
- */
186
- touch(cardId) {
187
- db.update(arcScorecards)
188
- .set({ lastUsedAt: Date.now() })
189
- .where(eq(arcScorecards.cardId, cardId))
190
- .run();
191
- },
192
- /**
193
- * Delete scorecards untouched for the retention window. Safe in a way the
194
- * old shape was not: a row holds no score, only a dead card id and its jar,
195
- * and a score is read back from the API on demand.
196
- *
197
- * Retention is measured on `lastUsedAt`, not `openedAt`, because that is the
198
- * column that says whether a card is *dead* — and "dead" is the only thing
199
- * that makes a row safe to drop. The two diverge for exactly the card this
200
- * ledger is built around: an agent playing regularly keeps one card alive
201
- * indefinitely by touching it every chunk, so an `openedAt` cutoff would
202
- * delete a card that is open, in use, and holding the jar its in-flight
203
- * plays need to read their own scores.
204
- *
205
- * Not called from anywhere in this plugin — a maintenance cron is the host's,
206
- * and a plugin has no way to schedule one. Each README says so.
207
- */
208
- cleanup() {
209
- const cutoff = Date.now() - SCORECARD_RETENTION_MS;
210
- db.delete(arcScorecards)
211
- .where(lt(arcScorecards.lastUsedAt, cutoff))
212
- .run();
213
- }
214
- };
215
- }
@@ -1,36 +0,0 @@
1
- import type { ToolFamilyContext, RecipeToolSet } from "@dynamicagents/core";
2
- /**
3
- * The `arc-game` tool family: act / inspect against the ARC-AGI-3 REST API. All
4
- * durable session state (cookies, guid, frames, metrics) lives in the workspace
5
- * at {@link ARC_SESSION_PATH}, so the run resumes across chunks and isolate
6
- * eviction. The API key is closed over from the plugin's config, never model
7
- * input.
8
- *
9
- * This family **plays**; it does not manage scorecards. The game arrives as a
10
- * validated Subtask param and the card as parent-resolved runtime (leased by
11
- * {@link file://./scorecard.ts}), so nothing here ever opens, closes, or chooses
12
- * a card.
13
- *
14
- * **Nothing here ever RESETs.** The play is opened once per (card, game) by the
15
- * parent (`resolvePlay`) and arrives as `runtime.guid`; this family only joins
16
- * it. That is the whole point: a guid is mintable only by RESET, and a second
17
- * RESET is a second run on the card, so a family that could reset would be able
18
- * to throw away a play by retrying it. Instead a WIN or GAME_OVER is the result
19
- * this card recorded for this game, and the model reports it.
20
- *
21
- * The session file is a local cache of that play, not its identity — the guid in
22
- * `runtime` is. A subagent that lost its workspace, or a re-dispatched Subtask,
23
- * rebuilds the file around the same guid and plays on.
24
- *
25
- * Transient ARC faults surface to the model as tool errors (the SDK captures a
26
- * throwing tool as an in-band `tool-error` result, not a rejected generation);
27
- * the soul tells the model to give up and report after repeated failures, and the
28
- * turn budget bounds it.
29
- */
30
- /**
31
- * This family's key in a Recipe's `toolFamilies`. Exported because it is also
32
- * what tells the parent a Subtask needs a scorecard leased before it can run —
33
- * see `resolveRuntime` in `./index.ts`.
34
- */
35
- export declare const ARC_GAME_FAMILY = "arc-game";
36
- export declare function buildArcGameTools(apiKey: string, ctx: ToolFamilyContext): RecipeToolSet;