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