@agentshouse/kit 0.1.0-alpha.8 → 0.2.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 (83) hide show
  1. package/README.md +14 -1740
  2. package/dist/api.js +11 -0
  3. package/dist/home.js +24 -0
  4. package/dist/house-main.js +4 -0
  5. package/dist/kit-main.js +16 -0
  6. package/dist/login.js +112 -0
  7. package/dist/resident.js +10 -0
  8. package/dist/stream.js +31 -0
  9. package/package.json +16 -11
  10. package/bin/connect-linux.sh +0 -134
  11. package/bin/kit.js +0 -1023
  12. package/bootstrap.json +0 -17
  13. package/src/acp.js +0 -99
  14. package/src/adapter-mcp.js +0 -44
  15. package/src/adapter.js +0 -252
  16. package/src/agent-logins.js +0 -65
  17. package/src/agents.js +0 -504
  18. package/src/apply.js +0 -29
  19. package/src/attach.js +0 -52
  20. package/src/binding.js +0 -90
  21. package/src/blocks.js +0 -156
  22. package/src/bridge.js +0 -449
  23. package/src/bytes.js +0 -89
  24. package/src/channel.js +0 -37
  25. package/src/command.js +0 -109
  26. package/src/configuration.js +0 -465
  27. package/src/connector-login.js +0 -91
  28. package/src/connector.js +0 -107
  29. package/src/continuation.js +0 -61
  30. package/src/contract.js +0 -363
  31. package/src/conversation-originals.js +0 -143
  32. package/src/custom/authorization.js +0 -63
  33. package/src/declaration.js +0 -35
  34. package/src/delivery.js +0 -191
  35. package/src/directory.js +0 -102
  36. package/src/draft.js +0 -89
  37. package/src/google/calendar.js +0 -177
  38. package/src/google/declared.js +0 -146
  39. package/src/google/drive.js +0 -435
  40. package/src/google/gateway.js +0 -166
  41. package/src/google/gmail.js +0 -249
  42. package/src/google/id.js +0 -1
  43. package/src/google/oauth.js +0 -273
  44. package/src/google/source.js +0 -25
  45. package/src/hook.js +0 -376
  46. package/src/host.js +0 -121
  47. package/src/house-main.js +0 -79
  48. package/src/house.js +0 -1090
  49. package/src/inbound.js +0 -175
  50. package/src/instance/google.js +0 -1
  51. package/src/kit-work-stream.js +0 -84
  52. package/src/launcher-main.js +0 -19
  53. package/src/launcher.js +0 -276
  54. package/src/local-files.js +0 -113
  55. package/src/login.js +0 -274
  56. package/src/mcp.js +0 -71
  57. package/src/migrator.js +0 -248
  58. package/src/mount.js +0 -582
  59. package/src/operation.js +0 -20
  60. package/src/original.js +0 -631
  61. package/src/peer.js +0 -124
  62. package/src/plan.js +0 -57
  63. package/src/question.js +0 -316
  64. package/src/refusal.js +0 -79
  65. package/src/repository.js +0 -521
  66. package/src/session-bin/house +0 -2
  67. package/src/settlement.js +0 -57
  68. package/src/setup.js +0 -190
  69. package/src/source-originals.js +0 -116
  70. package/src/source.js +0 -286
  71. package/src/starter-set/grilling/LICENSE +0 -21
  72. package/src/starter-set/grilling/SKILL.md +0 -30
  73. package/src/starter-set/grilling/agents/openai.yaml +0 -3
  74. package/src/starter-set.js +0 -17
  75. package/src/state.js +0 -157
  76. package/src/sync-library.js +0 -293
  77. package/src/sync-state.js +0 -120
  78. package/src/sync.js +0 -482
  79. package/src/telegram.js +0 -1045
  80. package/src/terminal.js +0 -57
  81. package/src/tmux.js +0 -119
  82. package/src/worker.js +0 -925
  83. package/src/workspace.js +0 -500
package/src/terminal.js DELETED
@@ -1,57 +0,0 @@
1
- import {
2
- EXECUTION_FAILURE_CAUSE_MAX,
3
- EXECUTION_OUTCOMES,
4
- PROVIDER_CAPACITY_EXHAUSTED,
5
- PROVIDER_CONTINUATION_UNAVAILABLE,
6
- PROVIDER_REFUSED,
7
- } from "./contract.js";
8
-
9
- export function reportedCause(failure) {
10
- const named =
11
- failure.detail === null || failure.detail === undefined
12
- ? failure.code
13
- : `${failure.code}: ${failure.detail}`;
14
- return named.slice(0, EXECUTION_FAILURE_CAUSE_MAX);
15
- }
16
-
17
- export function failedReport(failure) {
18
- return { outcome: "failed", cause: reportedCause(failure) };
19
- }
20
-
21
- export function terminalReport(observed) {
22
- if (observed.capacityExhausted) {
23
- return { outcome: "failed", cause: PROVIDER_CAPACITY_EXHAUSTED };
24
- }
25
- if (observed.providerRefused) {
26
- return { outcome: "failed", cause: PROVIDER_REFUSED };
27
- }
28
- if (observed.failure !== null && observed.failure !== undefined) {
29
- return failedReport(observed.failure);
30
- }
31
- if (observed.turnCompleted && !observed.conversation) return { outcome: "completed", cause: null };
32
- if (observed.continuable) return null;
33
- return { outcome: "failed", cause: PROVIDER_CONTINUATION_UNAVAILABLE };
34
- }
35
-
36
- export function reportedNote(reported) {
37
- return { operation: reported.operation, outcome: reported.outcome, cause: reported.cause };
38
- }
39
-
40
- export function retainedReport(stored) {
41
- if (stored === null || stored === undefined) return null;
42
- if (typeof stored !== "object" || Array.isArray(stored)) return undefined;
43
- if (typeof stored.operation !== "string" || stored.operation.length === 0) return undefined;
44
- if (!EXECUTION_OUTCOMES.includes(stored.outcome)) return undefined;
45
- if (stored.outcome === "completed") {
46
- if (stored.cause !== null) return undefined;
47
- return { operation: stored.operation, outcome: stored.outcome, cause: null };
48
- }
49
- if (
50
- typeof stored.cause !== "string" ||
51
- stored.cause.length === 0 ||
52
- stored.cause.length > EXECUTION_FAILURE_CAUSE_MAX
53
- ) {
54
- return undefined;
55
- }
56
- return { operation: stored.operation, outcome: stored.outcome, cause: stored.cause };
57
- }
package/src/tmux.js DELETED
@@ -1,119 +0,0 @@
1
- import { createHash, randomBytes } from "node:crypto";
2
- import { mkdir, writeFile } from "node:fs/promises";
3
- import { join } from "node:path";
4
- import { runCommand, withoutHouseCredentials } from "./command.js";
5
- import { TMUX_COMMAND_TIMEOUT_MS, TMUX_SUPPORTED_MINIMUM } from "./contract.js";
6
- import { KitRefusal } from "./refusal.js";
7
-
8
- const VERSION_LINE = /^tmux (?:next-)?(\d+)\.(\d+)/;
9
- const SESSION_NAME = /^[a-f0-9]{16}$/;
10
-
11
- const PREREQUISITE =
12
- `the Environment owner must install tmux ${TMUX_SUPPORTED_MINIMUM} or newer and make it reachable on PATH; ` +
13
- "House Kit never installs, upgrades, or replaces tmux";
14
-
15
- function parsedVersion(line) {
16
- const found = VERSION_LINE.exec(line.trim());
17
- return found === null ? null : [Number(found[1]), Number(found[2])];
18
- }
19
-
20
- const REQUIRED_VERSION = parsedVersion(`tmux ${TMUX_SUPPORTED_MINIMUM}`);
21
-
22
- const NAMESPACE_CONFIGURATION = "set-option -g -w remain-on-exit off\n";
23
-
24
- export function tmuxNamespace(directory) {
25
- return `house-kit-${createHash("sha256").update(directory).digest("hex").slice(0, 16)}`;
26
- }
27
-
28
- export function workerRuntime(directory, tmux) {
29
- return {
30
- tmux,
31
- namespace: tmuxNamespace(directory),
32
- configuration: join(directory, "tmux", "namespace.conf"),
33
- };
34
- }
35
-
36
- export function workerSessionName() {
37
- return randomBytes(8).toString("hex");
38
- }
39
-
40
- function namespaced(runtime, args) {
41
- return runCommand({
42
- command: [runtime.tmux, "-L", runtime.namespace, "-f", runtime.configuration, ...args],
43
- environment: {},
44
- stdin: "",
45
- timeoutMs: TMUX_COMMAND_TIMEOUT_MS,
46
- });
47
- }
48
-
49
- export async function readyTmux(runtime) {
50
- let reported;
51
- try {
52
- reported = await runCommand({
53
- command: [runtime.tmux, "-V"],
54
- environment: {},
55
- stdin: "",
56
- timeoutMs: TMUX_COMMAND_TIMEOUT_MS,
57
- });
58
- } catch (refusal) {
59
- if (refusal instanceof KitRefusal && refusal.code === "kit_command_unavailable") {
60
- throw new KitRefusal("kit_tmux_unavailable", PREREQUISITE);
61
- }
62
- throw refusal;
63
- }
64
- if (reported.status !== 0) throw new KitRefusal("kit_tmux_unavailable", PREREQUISITE);
65
- const found = parsedVersion(reported.stdout);
66
- if (found === null) {
67
- throw new KitRefusal(
68
- "kit_tmux_unsupported",
69
- `this Environment reports "${reported.stdout.trim()}"; ${PREREQUISITE}`,
70
- );
71
- }
72
- if (found[0] < REQUIRED_VERSION[0] || (found[0] === REQUIRED_VERSION[0] && found[1] < REQUIRED_VERSION[1])) {
73
- throw new KitRefusal(
74
- "kit_tmux_unsupported",
75
- `this Environment has tmux ${found[0]}.${found[1]}; ${PREREQUISITE}`,
76
- );
77
- }
78
- await mkdir(join(runtime.configuration, ".."), { recursive: true, mode: 0o700 });
79
- await writeFile(runtime.configuration, NAMESPACE_CONFIGURATION, { mode: 0o600 });
80
- return `${found[0]}.${found[1]}`;
81
- }
82
-
83
- export async function createSession(runtime, options) {
84
- if (!SESSION_NAME.test(options.session)) {
85
- throw new KitRefusal("kit_tmux_session_invalid", options.session);
86
- }
87
- const environment = Object.entries(withoutHouseCredentials(options.environment)).flatMap(
88
- ([name, value]) => ["-e", `${name}=${value}`],
89
- );
90
- const created = await namespaced(runtime, [
91
- "new-session",
92
- "-d",
93
- "-s",
94
- options.session,
95
- "-c",
96
- options.workingDirectory,
97
- ...environment,
98
- "--",
99
- ...options.command,
100
- ]);
101
- if (created.status !== 0) {
102
- throw new KitRefusal("kit_tmux_session_refused", created.stderr.trim() || null);
103
- }
104
- return options.session;
105
- }
106
-
107
- export async function sessionPresent(runtime, session) {
108
- const asked = await namespaced(runtime, ["has-session", "-t", `=${session}`]);
109
- return asked.status === 0;
110
- }
111
-
112
- export async function destroySession(runtime, session) {
113
- const killed = await namespaced(runtime, ["kill-session", "-t", `=${session}`]);
114
- if (killed.status === 0) return true;
115
- if (await sessionPresent(runtime, session)) {
116
- throw new KitRefusal("kit_tmux_session_persistent", session);
117
- }
118
- return false;
119
- }