@niwa-labs/rin 0.0.0-stage → 0.0.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/LICENSE +21 -0
- package/README.md +122 -2
- package/package.json +38 -4
- package/src/admission.ts +73 -0
- package/src/attention.ts +441 -0
- package/src/character.ts +171 -0
- package/src/charter.ts +130 -0
- package/src/cockpit/actions.ts +132 -0
- package/src/cockpit/index.tsx +13 -0
- package/src/cockpit/page.tsx +370 -0
- package/src/cockpit/view.ts +114 -0
- package/src/composition.ts +90 -0
- package/src/index.ts +16 -0
- package/src/plugin.ts +1071 -0
- package/src/presence.ts +57 -0
- package/src/records.ts +546 -0
- package/test/attention.test.ts +265 -0
- package/test/character.test.ts +42 -0
- package/test/charter.test.ts +84 -0
- package/test/cockpit-actions.test.ts +68 -0
- package/test/cockpit-view.test.ts +68 -0
- package/test/composition.test.ts +157 -0
- package/test/plugin.test.ts +988 -0
- package/test/presence.test.ts +38 -0
- package/tsconfig.json +16 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// Whether the owner is working now: the native sessions he attached, as their watch last saw them.
|
|
2
|
+
|
|
3
|
+
import { expect, test } from "bun:test";
|
|
4
|
+
|
|
5
|
+
import type { Row } from "../src/attention.ts";
|
|
6
|
+
import { workingNow } from "../src/presence.ts";
|
|
7
|
+
|
|
8
|
+
function rows(...given: Array<[string, unknown]>): Row[] {
|
|
9
|
+
return given.map(([type, data], index) => ({ type, data, at: (index + 1) * 1000, seq: index + 1 }));
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const s1 = { harness: "claude", native: "s1" };
|
|
13
|
+
const s2 = { harness: "codex", native: "s2" };
|
|
14
|
+
|
|
15
|
+
test("an attached session works until it pauses, ends or is let go of", () => {
|
|
16
|
+
const attached = rows(
|
|
17
|
+
["agent.attached", { agent: "rin", session: "claude s1", cwd: "/work/a" }],
|
|
18
|
+
["agent.attached", { agent: "lead", session: "codex s2", cwd: "/work/b" }],
|
|
19
|
+
);
|
|
20
|
+
expect(workingNow(attached).map((one) => one.session)).toEqual(["claude s1", "codex s2"]);
|
|
21
|
+
expect(workingNow([...attached, ...rows(["history.session.paused", { session: s1, upto: "l1", why: "idle" }])].map(renumber)).map((one) => one.session)).toEqual(["codex s2"]);
|
|
22
|
+
expect(workingNow([...attached, ...rows(["history.session.ended", { session: s2, certainty: "guessed", why: "idle" }])].map(renumber)).map((one) => one.session)).toEqual(["claude s1"]);
|
|
23
|
+
expect(workingNow([...attached, ...rows(["agent.detached", { agent: "rin", session: "claude s1" }])].map(renumber)).map((one) => one.session)).toEqual(["codex s2"]);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test("progress after a pause says he is back", () => {
|
|
27
|
+
const back = rows(
|
|
28
|
+
["agent.attached", { agent: "rin", session: "claude s1", cwd: "/work/a" }],
|
|
29
|
+
["history.session.paused", { session: s1, upto: "l1", why: "idle" }],
|
|
30
|
+
["session.progress", { session: s1, done: 2, total: 5 }],
|
|
31
|
+
);
|
|
32
|
+
expect(workingNow(back)).toEqual([{ session: "claude s1", cwd: "/work/a", agent: "rin" }]);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
/** Rows put together from two lists, numbered again in order. */
|
|
36
|
+
function renumber(row: Row, index: number): Row {
|
|
37
|
+
return { ...row, seq: index + 1, at: (index + 1) * 1000 };
|
|
38
|
+
}
|