@timqi/pier 0.1.0 → 0.1.1
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 +58 -125
- package/dist/agent/config.js +6 -15
- package/dist/agent/credentials.js +11 -23
- package/dist/agent/events.js +42 -64
- package/dist/agent/listing.js +39 -92
- package/dist/agent/pi.js +103 -252
- package/dist/boards/boards.js +19 -29
- package/dist/channels/attach.js +14 -42
- package/dist/channels/chains.js +33 -37
- package/dist/channels/chunk.js +8 -28
- package/dist/channels/commands.js +3 -14
- package/dist/channels/config.js +33 -52
- package/dist/channels/control.js +4 -13
- package/dist/channels/conversations.js +8 -25
- package/dist/channels/dedup.js +8 -17
- package/dist/channels/gatekeeper.js +13 -23
- package/dist/channels/lark-api.js +23 -63
- package/dist/channels/lark-outbound.js +12 -44
- package/dist/channels/lark-panel.js +7 -23
- package/dist/channels/lark-render.js +18 -62
- package/dist/channels/lark.js +52 -141
- package/dist/channels/lines.js +13 -15
- package/dist/channels/panel.js +16 -36
- package/dist/channels/receipts.js +29 -52
- package/dist/channels/routes.js +3 -9
- package/dist/channels/runtime.js +12 -23
- package/dist/channels/slack-api.js +34 -86
- package/dist/channels/slack-directory.js +7 -23
- package/dist/channels/slack-outbound.js +12 -56
- package/dist/channels/slack-panel.js +4 -13
- package/dist/channels/slack-render.js +23 -91
- package/dist/channels/slack-tool.js +48 -171
- package/dist/channels/slack.js +73 -239
- package/dist/channels/telegram-api.js +8 -20
- package/dist/channels/telegram-panel.js +5 -21
- package/dist/channels/telegram-render.js +13 -40
- package/dist/channels/telegram.js +54 -146
- package/dist/channels/types.js +5 -16
- package/dist/cli.js +17 -41
- package/dist/config-sync.js +87 -4
- package/dist/core/hub.js +7 -20
- package/dist/core/identity.js +20 -59
- package/dist/core/inbound-file.js +15 -49
- package/dist/core/inbox.js +12 -34
- package/dist/core/queue.js +3 -5
- package/dist/core/reply.js +41 -142
- package/dist/core/router.js +209 -264
- package/dist/core/types.js +4 -0
- package/dist/db.js +88 -272
- package/dist/drain.js +57 -50
- package/dist/extensions/index.js +3 -11
- package/dist/extensions/web/anthropic.js +3 -9
- package/dist/extensions/web/artifacts.js +2 -5
- package/dist/extensions/web/content.js +4 -12
- package/dist/extensions/web/http.js +2 -6
- package/dist/extensions/web/language.js +8 -18
- package/dist/extensions/web/openai.js +1 -1
- package/dist/extensions/web/provider.js +5 -18
- package/dist/extensions/web/tools.js +19 -63
- package/dist/lock.js +98 -0
- package/dist/log.js +9 -26
- package/dist/main.js +84 -183
- package/dist/paths.js +10 -26
- package/dist/secrets.js +18 -45
- package/dist/service.js +31 -73
- package/dist/settings.js +19 -63
- package/dist/tasks/agent.js +24 -45
- package/dist/tasks/callbacks.js +8 -16
- package/dist/tasks/command.js +2 -6
- package/dist/tasks/definitions.js +39 -62
- package/dist/tasks/execution.js +41 -39
- package/dist/tasks/groups.js +8 -11
- package/dist/tasks/messages.js +88 -155
- package/dist/tasks/outbox.js +33 -54
- package/dist/tasks/routes.js +4 -7
- package/dist/tasks/runs.js +4 -9
- package/dist/tasks/service.js +29 -42
- package/dist/tasks/store.js +36 -27
- package/dist/tasks/tool.js +59 -60
- package/dist/tools-task.js +20 -60
- package/dist/tools.js +98 -325
- package/dist/update.js +20 -43
- package/dist/web/auth.js +118 -179
- package/dist/web/config-sync.js +2 -2
- package/dist/web/config.js +3 -7
- package/dist/web/explorer.js +10 -21
- package/dist/web/fs.js +20 -42
- package/dist/web/instance.js +35 -82
- package/dist/web/providers.js +5 -11
- package/dist/web/public/assets/{activity-Bl3vZukb.js → activity-B89_hH7q.js} +1 -1
- package/dist/web/public/assets/activity-B89_hH7q.js.br +0 -0
- package/dist/web/public/assets/activity-B89_hH7q.js.gz +0 -0
- package/dist/web/public/assets/{boards-DYuf4Mlj.js → boards-BeKW0ZXK.js} +1 -1
- package/dist/web/public/assets/boards-BeKW0ZXK.js.br +0 -0
- package/dist/web/public/assets/boards-BeKW0ZXK.js.gz +0 -0
- package/dist/web/public/assets/explorer-DIuMlaV3.js +4 -0
- package/dist/web/public/assets/explorer-DIuMlaV3.js.br +0 -0
- package/dist/web/public/assets/explorer-DIuMlaV3.js.gz +0 -0
- package/dist/web/public/assets/index-DzXDXra_.js +85 -0
- package/dist/web/public/assets/index-DzXDXra_.js.br +0 -0
- package/dist/web/public/assets/index-DzXDXra_.js.gz +0 -0
- package/dist/web/public/assets/index-eqQLVS8Q.css +2 -0
- package/dist/web/public/assets/index-eqQLVS8Q.css.br +0 -0
- package/dist/web/public/assets/index-eqQLVS8Q.css.gz +0 -0
- package/dist/web/public/assets/{runs-BLJu7EXN.js → runs-Cwy0mN8i.js} +1 -1
- package/dist/web/public/assets/runs-Cwy0mN8i.js.br +0 -0
- package/dist/web/public/assets/runs-Cwy0mN8i.js.gz +0 -0
- package/dist/web/public/assets/{settings-BrdVh-Zi.js → settings-DzZLmujq.js} +1 -1
- package/dist/web/public/assets/settings-DzZLmujq.js.br +0 -0
- package/dist/web/public/assets/settings-DzZLmujq.js.gz +0 -0
- package/dist/web/public/assets/{task-runs-CeQS1rxa.js → task-runs-BCakxFk8.js} +1 -1
- package/dist/web/public/assets/task-runs-BCakxFk8.js.br +0 -0
- package/dist/web/public/assets/task-runs-BCakxFk8.js.gz +0 -0
- package/dist/web/public/assets/tasks-BlzEbk11.js +4 -0
- package/dist/web/public/assets/tasks-BlzEbk11.js.br +0 -0
- package/dist/web/public/assets/tasks-BlzEbk11.js.gz +0 -0
- package/dist/web/public/index.html +30 -16
- package/dist/web/public/index.html.br +0 -0
- package/dist/web/public/index.html.gz +0 -0
- package/dist/web/public/sw.js +14 -2
- package/dist/web/public/sw.js.br +0 -0
- package/dist/web/public/sw.js.gz +0 -0
- package/dist/web/push.js +55 -77
- package/dist/web/route.js +3 -7
- package/dist/web/server.js +109 -190
- package/dist/web/session-state.js +13 -53
- package/dist/web/types.js +2 -4
- package/dist/web/webpush.js +10 -25
- package/docs/deploy.md +115 -330
- package/package.json +1 -1
- package/skills/pier-boards/SKILL.md +81 -160
- package/skills/pier-help/SKILL.md +23 -20
- package/skills/pier-slack/SKILL.md +2 -2
- package/skills/pier-tasks/SKILL.md +23 -15
- package/dist/config-sync-fetch.js +0 -84
- package/dist/limits.js +0 -14
- package/dist/web/public/assets/activity-Bl3vZukb.js.br +0 -0
- package/dist/web/public/assets/activity-Bl3vZukb.js.gz +0 -0
- package/dist/web/public/assets/boards-DYuf4Mlj.js.br +0 -0
- package/dist/web/public/assets/boards-DYuf4Mlj.js.gz +0 -0
- package/dist/web/public/assets/explorer-qJH_9nTE.js +0 -4
- package/dist/web/public/assets/explorer-qJH_9nTE.js.br +0 -0
- package/dist/web/public/assets/explorer-qJH_9nTE.js.gz +0 -0
- package/dist/web/public/assets/index-Dqdb-Eqt.js +0 -85
- package/dist/web/public/assets/index-Dqdb-Eqt.js.br +0 -0
- package/dist/web/public/assets/index-Dqdb-Eqt.js.gz +0 -0
- package/dist/web/public/assets/index-DzmMzvi_.css +0 -2
- package/dist/web/public/assets/index-DzmMzvi_.css.br +0 -0
- package/dist/web/public/assets/index-DzmMzvi_.css.gz +0 -0
- package/dist/web/public/assets/runs-BLJu7EXN.js.br +0 -0
- package/dist/web/public/assets/runs-BLJu7EXN.js.gz +0 -0
- package/dist/web/public/assets/settings-BrdVh-Zi.js.br +0 -0
- package/dist/web/public/assets/settings-BrdVh-Zi.js.gz +0 -0
- package/dist/web/public/assets/task-runs-CeQS1rxa.js.br +0 -0
- package/dist/web/public/assets/task-runs-CeQS1rxa.js.gz +0 -0
- package/dist/web/public/assets/tasks-bcb3fYdK.js +0 -4
- package/dist/web/public/assets/tasks-bcb3fYdK.js.br +0 -0
- package/dist/web/public/assets/tasks-bcb3fYdK.js.gz +0 -0
package/dist/tools-task.js
CHANGED
|
@@ -1,36 +1,21 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
// It lives beside tools.ts rather than inside it because tools.ts may not
|
|
6
|
-
// import tasks/, and outside main.ts because main.ts is wiring: this is the
|
|
7
|
-
// only rule in the instance layer that is neither construction nor a callback.
|
|
8
|
-
// The task's run history *is* the tools status surface — the install, the daily
|
|
9
|
-
// update and every failure are runs with output, so there is no second place to
|
|
10
|
-
// look (§5b).
|
|
1
|
+
// A tools switch becomes exactly one run of the one task Pier owns. Beside
|
|
2
|
+
// tools.ts because tools.ts may not import tasks/; the task's run history is
|
|
3
|
+
// the tools status surface (§5).
|
|
11
4
|
import { existsSync } from "node:fs";
|
|
12
5
|
import { fileURLToPath } from "node:url";
|
|
13
6
|
import { logger } from "./log.js";
|
|
14
7
|
import { PIER_HOME } from "./paths.js";
|
|
15
8
|
import { isTerminal } from "./tasks/types.js";
|
|
16
9
|
import { coalescedSync } from "./tools.js";
|
|
17
|
-
/**
|
|
18
|
-
* rather than one a person wrote, and names itself with it when it writes the
|
|
19
|
-
* definition back (the owner guard in tasks/definitions.ts). */
|
|
10
|
+
/** The owner guard in tasks/definitions.ts: only this creator may write it back. */
|
|
20
11
|
const TOOLS_TASK_CREATOR = "tools";
|
|
21
|
-
//
|
|
22
|
-
// anything an operator greps the journal for.
|
|
12
|
+
// "pier", not "tools": what an operator greps the journal for.
|
|
23
13
|
const log = logger("pier");
|
|
24
|
-
/** POSIX single quotes:
|
|
25
|
-
* double quotes, and this string is run by bash months from now. */
|
|
14
|
+
/** POSIX single quotes: this string is run by bash months from now. */
|
|
26
15
|
const shellQuote = (value) => `'${value.replaceAll("'", `'\\''`)}'`;
|
|
27
|
-
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* types through imports that still say `.js`, so it is the same command under
|
|
31
|
-
* tsx — which is what a source checkout has. Neither available is a refusal
|
|
32
|
-
* with a reason, never a task whose script cannot run.
|
|
33
|
-
*/
|
|
16
|
+
/** From a source checkout there is no `cli.js` and node cannot strip types
|
|
17
|
+
* through `.js` imports, so it is the same command under tsx. Neither
|
|
18
|
+
* available is a refusal with a reason, never a task whose script cannot run. */
|
|
34
19
|
const toolsSyncScript = () => {
|
|
35
20
|
const built = fileURLToPath(new URL("./cli.js", import.meta.url));
|
|
36
21
|
if (existsSync(built))
|
|
@@ -49,22 +34,10 @@ const toolsSyncScript = () => {
|
|
|
49
34
|
}
|
|
50
35
|
};
|
|
51
36
|
export function toolsTask(tasks) {
|
|
52
|
-
/** Which task is Pier's, and the id every managed run goes through. */
|
|
53
37
|
let toolsTaskId = null;
|
|
54
|
-
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* Created once and never retired: a task that comes and goes is a state class
|
|
58
|
-
* of its own (two boots racing to create it, a retirement racing a switch),
|
|
59
|
-
* and the run it would have been retired for already says "no tools switched
|
|
60
|
-
* on".
|
|
61
|
-
*
|
|
62
|
-
* It repairs rather than trusts because of what came before the owner guard
|
|
63
|
-
* (tasks/definitions.ts): a definition edited by an older Pier, or by a
|
|
64
|
-
* release where the routes could still write it, is brought back to the one
|
|
65
|
-
* Pier owns here. Nothing can edit it any more — so this is a boot-time
|
|
66
|
-
* repair of state that already exists, not a defence.
|
|
67
|
-
*/
|
|
38
|
+
/** Created once and never retired: a task that comes and goes is a state
|
|
39
|
+
* class of its own, and a run with nothing on already says so. Repairs a
|
|
40
|
+
* definition an older Pier could still edit. */
|
|
68
41
|
const ensureToolsTask = async () => {
|
|
69
42
|
const command = toolsSyncScript();
|
|
70
43
|
if ("problem" in command)
|
|
@@ -83,40 +56,31 @@ export function toolsTask(tasks) {
|
|
|
83
56
|
callback: { type: "none" },
|
|
84
57
|
timeoutSeconds: 1800,
|
|
85
58
|
};
|
|
86
|
-
//
|
|
87
|
-
// replacement is a new one and the old one keeps its history.
|
|
59
|
+
// Nothing can un-archive a task, so an archived one is replaced, history kept.
|
|
88
60
|
const owned = tasks.list().filter((task) => task.creator === TOOLS_TASK_CREATOR && !task.archived);
|
|
89
|
-
//
|
|
90
|
-
// reporting the other's run as an overlap.
|
|
61
|
+
// Two would fight over ubix's state lock every night.
|
|
91
62
|
for (const extra of owned.slice(1)) {
|
|
92
63
|
log.warn(`archiving a second tools update task (${extra.id})`);
|
|
93
64
|
tasks.archive(extra.id, TOOLS_TASK_CREATOR);
|
|
94
65
|
}
|
|
95
66
|
const task = owned[0];
|
|
96
|
-
// Every field
|
|
97
|
-
//
|
|
98
|
-
// while the daily run never happens.
|
|
67
|
+
// Every field, not just the command: a paused or renamed task still claims
|
|
68
|
+
// to keep the tools current while the daily run never happens.
|
|
99
69
|
if (task && Object.entries(draft).some(([key, value]) => JSON.stringify(task[key]) !== JSON.stringify(value))) {
|
|
100
70
|
log.warn("the tools update task was edited — restoring the definition Pier owns");
|
|
101
|
-
// Named as the owner: this is the one path allowed to write it back
|
|
102
|
-
// (tasks/definitions.ts).
|
|
103
71
|
await tasks.update(task.id, draft, TOOLS_TASK_CREATOR);
|
|
104
72
|
}
|
|
105
73
|
const id = task ? task.id : (await tasks.create(draft, TOOLS_TASK_CREATOR)).id;
|
|
106
74
|
toolsTaskId = id;
|
|
107
75
|
return { id };
|
|
108
76
|
};
|
|
109
|
-
/** The half of `coalescedSync` (tools.ts
|
|
110
|
-
* knows what a task is: start a run, and hand back what to wait for — our own
|
|
111
|
-
* run, or the one already in flight that made ours a `skipped` row. */
|
|
77
|
+
/** The half of `coalescedSync` (tools.ts) that knows what a task is. */
|
|
112
78
|
const requestSync = coalescedSync(() => {
|
|
113
79
|
if (!toolsTaskId)
|
|
114
80
|
throw new Error("no tools update task to run");
|
|
115
81
|
const settled = (id) => tasks.waitForRun(id).then(() => undefined);
|
|
116
|
-
//
|
|
117
|
-
//
|
|
118
|
-
// something to spin on. Three refusals in a row with nothing running is a
|
|
119
|
-
// bug, and it is reported as one rather than retried forever.
|
|
82
|
+
// A run can finish between being in flight and being asked about; three
|
|
83
|
+
// refusals with nothing running is a bug, reported rather than retried.
|
|
120
84
|
for (let attempt = 0; attempt < 3; attempt++) {
|
|
121
85
|
const mine = tasks.run(toolsTaskId, null, "manual");
|
|
122
86
|
if (!isTerminal(mine.state))
|
|
@@ -127,8 +91,6 @@ export function toolsTask(tasks) {
|
|
|
127
91
|
}
|
|
128
92
|
throw new Error("the tools sync was refused as an overlap three times with nothing running");
|
|
129
93
|
}, (err) => log.error("the tools sync could not be run", err));
|
|
130
|
-
/** A switch was flipped: make sure the task is the one Pier means, then ask
|
|
131
|
-
* for a sync. Answers with what that switch should say about it. */
|
|
132
94
|
const toolsChanged = async () => {
|
|
133
95
|
try {
|
|
134
96
|
const task = await ensureToolsTask();
|
|
@@ -144,10 +106,8 @@ export function toolsTask(tasks) {
|
|
|
144
106
|
}
|
|
145
107
|
};
|
|
146
108
|
return {
|
|
147
|
-
/**
|
|
148
|
-
* otherwise both find no task and create one each. */
|
|
109
|
+
/** At boot, before any route exists: two first flips could otherwise both create one. */
|
|
149
110
|
reconcile: ensureToolsTask,
|
|
150
|
-
/** The task whose runs are the status surface, null until there is one. */
|
|
151
111
|
id: () => toolsTaskId,
|
|
152
112
|
changed: toolsChanged,
|
|
153
113
|
};
|