zigmini 1.0.0-beta.2 → 1.1.0-beta.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.
Files changed (141) hide show
  1. package/README.ko.md +36 -3
  2. package/README.md +36 -3
  3. package/assets/agent/gateway-request-rules.md +1 -1
  4. package/assets/agent/gateway-rules.md +6 -1
  5. package/assets/android/zigmini.apk +0 -0
  6. package/assets/android/zigmini.apk.json +3 -3
  7. package/assets/build.json +1 -1
  8. package/assets/document-reader/document-reader +0 -0
  9. package/assets/document-reader/host-selector +0 -0
  10. package/assets/document-reader/manifest.json +27 -0
  11. package/docs/manual.ko.md +120 -11
  12. package/docs/manual.md +123 -12
  13. package/host/document-reader/DocumentRead.swift +370 -0
  14. package/host/document-reader/HostSelector.swift +192 -0
  15. package/host/document-reader/Protocol.swift +647 -0
  16. package/host/document-reader/main.swift +22 -0
  17. package/host/omo-bridge/agent-aside-tool.ts +119 -0
  18. package/host/omo-bridge/agent-aside.ts +522 -0
  19. package/host/omo-bridge/agent-collaboration-files.ts +282 -0
  20. package/host/omo-bridge/agent-collaboration.ts +385 -0
  21. package/host/omo-bridge/agent-control.ts +400 -28
  22. package/host/omo-bridge/agent-execution.sb +42 -0
  23. package/host/omo-bridge/agent-execution.ts +158 -0
  24. package/host/omo-bridge/agent-tool-adapters.ts +388 -0
  25. package/host/omo-bridge/agent-tool-permissions.ts +96 -0
  26. package/host/omo-bridge/aside-tabs.ts +41 -0
  27. package/host/omo-bridge/attachment-read.ts +100 -0
  28. package/host/omo-bridge/bridge.ts +10 -0
  29. package/host/omo-bridge/managed-call.ts +46 -0
  30. package/host/omo-bridge/task-control.ts +39 -5
  31. package/host/omo-check/patches/attachments-293/README.md +138 -0
  32. package/host/omo-check/patches/attachments-293/document-content.js +234 -0
  33. package/host/omo-check/patches/attachments-293/document-content.types.txt +91 -0
  34. package/host/omo-check/patches/attachments-293/omo-5.1.51-documents.patch +831 -0
  35. package/host/omo-check/patches/attachments-293/omo-5.1.51-gateway-port.manifest.json +471 -0
  36. package/host/omo-check/patches/omo-5.1.51-agent-tool-authority.patch +471 -0
  37. package/host/omo-check/patches/omo-5.1.51-chatgpt-terra.patch +21 -0
  38. package/host/omo-check/patches/omo-5.1.51-gateway-port.manifest.json +44 -6
  39. package/host/omo-check/patches/omo-5.1.51-memory-receipts.patch +5 -0
  40. package/package.json +5 -3
  41. package/src/agent/api.ts +345 -20
  42. package/src/agent/artifacts.ts +196 -0
  43. package/src/agent/aside-target-routes.ts +369 -0
  44. package/src/agent/aside-targets.ts +215 -0
  45. package/src/agent/collaboration-admission.ts +47 -0
  46. package/src/agent/collaboration-read.ts +117 -0
  47. package/src/agent/collaboration-session.ts +196 -0
  48. package/src/agent/collaboration-types.ts +258 -0
  49. package/src/agent/collaboration.ts +399 -0
  50. package/src/agent/definition.ts +65 -3
  51. package/src/agent/fields.ts +9 -3
  52. package/src/agent/file-core.ts +325 -0
  53. package/src/agent/files.ts +87 -8
  54. package/src/agent/list.ts +3 -3
  55. package/src/agent/managed-call.ts +144 -0
  56. package/src/agent/tool-catalog.ts +184 -0
  57. package/src/agent/tool-delivery.ts +359 -0
  58. package/src/agent/tool-permission-types.ts +81 -0
  59. package/src/agent/tool-permissions.ts +1366 -0
  60. package/src/attachments/api.ts +161 -0
  61. package/src/attachments/document-reader.ts +325 -0
  62. package/src/attachments/host-selector.ts +410 -0
  63. package/src/attachments/managed-binding.ts +83 -0
  64. package/src/attachments/prepare.ts +214 -0
  65. package/src/attachments/selector-port.ts +28 -0
  66. package/src/attachments/service.ts +729 -0
  67. package/src/attachments/store.ts +698 -0
  68. package/src/attachments/types.ts +123 -0
  69. package/src/cli/doctor.ts +30 -10
  70. package/src/decisions.ts +109 -10
  71. package/src/engine/apply-patch.ts +21 -0
  72. package/src/engine/compat.json +2 -1
  73. package/src/engine/install.ts +45 -4
  74. package/src/engine/sandbox-cell.ts +2 -0
  75. package/src/gc.ts +33 -225
  76. package/src/housekeeping/api.ts +163 -0
  77. package/src/housekeeping/audit.ts +61 -0
  78. package/src/housekeeping/collectors/agent-collaboration.ts +33 -0
  79. package/src/housekeeping/collectors/agent-drafts.ts +43 -0
  80. package/src/housekeeping/collectors/agent-file-trash.ts +36 -0
  81. package/src/housekeeping/collectors/agent-trash.ts +28 -0
  82. package/src/housekeeping/collectors/attachment-cleanup.ts +35 -0
  83. package/src/housekeeping/collectors/db-backup.ts +25 -0
  84. package/src/housekeeping/collectors/docker-build-cache.ts +29 -0
  85. package/src/housekeeping/collectors/docker-image.ts +135 -0
  86. package/src/housekeeping/collectors/omo-version.ts +32 -0
  87. package/src/housekeeping/collectors/orphan-test-process.ts +205 -0
  88. package/src/housekeeping/collectors/reconcile-work.ts +55 -0
  89. package/src/housekeeping/collectors/rpc-daemon.ts +39 -0
  90. package/src/housekeeping/collectors/shared.ts +149 -0
  91. package/src/housekeeping/collectors/temp-dir.ts +28 -0
  92. package/src/housekeeping/collectors/update-file.ts +25 -0
  93. package/src/housekeeping/collectors/worktree.ts +193 -0
  94. package/src/housekeeping/engine.ts +125 -0
  95. package/src/housekeeping/reconcile/work.ts +130 -0
  96. package/src/housekeeping/registry.ts +63 -0
  97. package/src/housekeeping/trash.ts +59 -0
  98. package/src/housekeeping/types.ts +31 -0
  99. package/src/hub.ts +1095 -41
  100. package/src/main.ts +230 -31
  101. package/src/message-references.ts +14 -5
  102. package/src/profile-prompt.ts +13 -1
  103. package/src/profile.ts +13 -5
  104. package/src/protocol.ts +41 -6
  105. package/src/security-allow.ts +79 -2
  106. package/src/security-check.ts +1 -1
  107. package/src/store.ts +1946 -23
  108. package/src/test-crash.ts +20 -0
  109. package/src/usage.ts +18 -7
  110. package/src/work-watch.ts +55 -7
  111. package/src/work.ts +192 -3
  112. package/web/DESIGN.md +35 -1
  113. package/web/agents.d.ts +189 -12
  114. package/web/agents.js +898 -39
  115. package/web/app.js +2634 -210
  116. package/web/attachments.d.ts +91 -0
  117. package/web/attachments.js +422 -0
  118. package/web/collaboration.d.ts +87 -0
  119. package/web/collaboration.js +290 -0
  120. package/web/decisions.d.ts +39 -2
  121. package/web/decisions.js +354 -2
  122. package/web/gc.d.ts +26 -5
  123. package/web/gc.js +113 -13
  124. package/web/i18n/agents.d.ts +4 -0
  125. package/web/i18n/agents.js +200 -8
  126. package/web/i18n/attachments.js +78 -0
  127. package/web/i18n/decisions.d.ts +4 -0
  128. package/web/i18n/decisions.js +68 -0
  129. package/web/i18n/gc.d.ts +4 -0
  130. package/web/i18n/gc.js +184 -2
  131. package/web/i18n/main.js +80 -8
  132. package/web/i18n/tour.d.ts +4 -0
  133. package/web/i18n/tour.js +37 -0
  134. package/web/index.html +20 -3
  135. package/web/profile.d.ts +2 -2
  136. package/web/profile.js +16 -10
  137. package/web/style.css +342 -21
  138. package/web/tooltip.d.ts +2 -0
  139. package/web/tooltip.js +12 -0
  140. package/web/tour.d.ts +57 -0
  141. package/web/tour.js +450 -0
@@ -0,0 +1,63 @@
1
+ import { agentCollaborationCleanup, type AgentCollaborationCleanupDeps } from "./collectors/agent-collaboration.ts";
2
+ import { agentDrafts } from "./collectors/agent-drafts.ts";
3
+ import { agentFileTrash } from "./collectors/agent-file-trash.ts";
4
+ import { agentTrash } from "./collectors/agent-trash.ts";
5
+ import { attachmentCleanup, type AttachmentCleanupDeps } from "./collectors/attachment-cleanup.ts";
6
+ import { dbBackup } from "./collectors/db-backup.ts";
7
+ import { dockerBuildCache } from "./collectors/docker-build-cache.ts";
8
+ import { type DockerDeps, dockerImage } from "./collectors/docker-image.ts";
9
+ import { omoVersion } from "./collectors/omo-version.ts";
10
+ import { type OrphanDeps, orphanTestProcess } from "./collectors/orphan-test-process.ts";
11
+ import { reconcileWork, type ReconcileWorkDeps } from "./collectors/reconcile-work.ts";
12
+ import { rpcDaemon } from "./collectors/rpc-daemon.ts";
13
+ import type { GcCollector, GcContext } from "./collectors/shared.ts";
14
+ import { tempDir } from "./collectors/temp-dir.ts";
15
+ import { updateFile } from "./collectors/update-file.ts";
16
+ import { worktree, type WorktreeDeps } from "./collectors/worktree.ts";
17
+ import type { BoundCollector, Collector } from "./types.ts";
18
+
19
+ export function bind<D>(collector: Collector<D>, deps: D): BoundCollector {
20
+ return {
21
+ name: collector.name,
22
+ role: collector.role,
23
+ triggers: collector.triggers,
24
+ confirmation: collector.confirmation,
25
+ reversibility: collector.reversibility,
26
+ find: () => collector.find(deps),
27
+ judge: (c) => collector.judge(c, deps),
28
+ act: (c) => collector.act(c, deps),
29
+ };
30
+ }
31
+
32
+ /**
33
+ * The six kinds of improvement 66, in the order the old /api/gc report lists them (src/gc.ts runs these too), then the
34
+ * later file kinds that the old report lists too.
35
+ */
36
+ export const GC_COLLECTORS: readonly GcCollector[] = [dbBackup, agentTrash, omoVersion, updateFile, tempDir, rpcDaemon, agentFileTrash, agentDrafts];
37
+
38
+ export interface RegistryDeps {
39
+ readonly gc: GcContext;
40
+ readonly orphan: OrphanDeps;
41
+ readonly worktree: WorktreeDeps;
42
+ readonly docker: DockerDeps;
43
+ readonly reconcile: ReconcileWorkDeps;
44
+ readonly attachments?: AttachmentCleanupDeps;
45
+ readonly collaboration?: AgentCollaborationCleanupDeps;
46
+ }
47
+
48
+ /**
49
+ * Every registered collector, in report order: the six ported kinds first (the old /api/gc order), then the later ones
50
+ * appended. Adding a target = one collector file + one line here.
51
+ */
52
+ export function registry(deps: RegistryDeps): BoundCollector[] {
53
+ return [
54
+ ...GC_COLLECTORS.map((c) => bind(c, deps.gc)),
55
+ bind(orphanTestProcess, deps.orphan),
56
+ bind(worktree, deps.worktree),
57
+ bind(dockerImage, deps.docker),
58
+ bind(dockerBuildCache, deps.docker),
59
+ bind(reconcileWork, deps.reconcile),
60
+ ...(deps.attachments ? [bind(attachmentCleanup, deps.attachments)] : []),
61
+ ...(deps.collaboration ? [bind(agentCollaborationCleanup, deps.collaboration)] : []),
62
+ ];
63
+ }
@@ -0,0 +1,59 @@
1
+ import { existsSync, rmSync } from "node:fs";
2
+ import { isAbsolute, sep } from "node:path";
3
+
4
+ /**
5
+ * Housekeeping removes files and folders by moving them to the macOS Trash (installation rule "삭제는 휴지통").
6
+ * Order: test-only `ZGW_TRASH_BIN` (never set in production) -> `/usr/bin/trash` -> Finder through osascript. The path is
7
+ * always one argv entry, never part of a shell or AppleScript string. With neither command (the checkout container) only a
8
+ * `db-backup` is deleted for good, reported as method "deleted", why "no_macos_trash"; anything else fails and stays.
9
+ */
10
+
11
+ export const TRASH_BIN = "/usr/bin/trash";
12
+ export const OSASCRIPT_BIN = "/usr/bin/osascript";
13
+ const FINDER_DELETE = ["on run argv", "tell application \"Finder\" to delete (POSIX file (item 1 of argv))", "end run"];
14
+
15
+ export interface TrashResult { readonly ok: boolean; readonly method: "trash" | "deleted"; readonly error?: string; readonly why?: string }
16
+ export type Trash = (path: string, collector: string) => Promise<TrashResult>;
17
+
18
+ export interface TrashTools {
19
+ readonly env: Readonly<Record<string, string | undefined>>;
20
+ readonly exists: (bin: string) => boolean;
21
+ readonly run: (argv: readonly string[]) => Promise<{ code: number; stderr: string }>;
22
+ }
23
+
24
+ export function systemTrashTools(): TrashTools {
25
+ return {
26
+ env: process.env,
27
+ exists: existsSync,
28
+ run: async (argv) => {
29
+ const child = Bun.spawn([...argv], { stdin: "ignore", stdout: "ignore", stderr: "pipe" });
30
+ const stderr = await new Response(child.stderr).text();
31
+ return { code: await child.exited, stderr: stderr.trim() };
32
+ },
33
+ };
34
+ }
35
+
36
+ function command(path: string, tools: TrashTools): string[] | null {
37
+ const fake = tools.env.ZGW_TRASH_BIN;
38
+ if (fake !== undefined && fake !== "") return [fake, path];
39
+ if (tools.exists(TRASH_BIN)) return [TRASH_BIN, path];
40
+ if (tools.exists(OSASCRIPT_BIN)) return [OSASCRIPT_BIN, ...FINDER_DELETE.flatMap((line) => ["-e", line]), path];
41
+ return null;
42
+ }
43
+
44
+ export async function moveToTrash(path: string, collector = "", tools: TrashTools = systemTrashTools()): Promise<TrashResult> {
45
+ if (!isAbsolute(path) || path.split(sep).includes("..")) return { ok: false, method: "trash", error: "path_rejected" };
46
+ const argv = command(path, tools);
47
+ if (argv === null) {
48
+ if (collector !== "db-backup") return { ok: false, method: "trash", error: "no_macos_trash" };
49
+ rmSync(path, { recursive: true });
50
+ return { ok: true, method: "deleted", why: "no_macos_trash" };
51
+ }
52
+ try {
53
+ const run = await tools.run(argv);
54
+ if (run.code !== 0) return { ok: false, method: "trash", error: `trash_exit_${run.code}${run.stderr === "" ? "" : `: ${run.stderr}`}` };
55
+ } catch (error) {
56
+ return { ok: false, method: "trash", error: error instanceof Error ? error.message : String(error) };
57
+ }
58
+ return { ok: true, method: "trash" };
59
+ }
@@ -0,0 +1,31 @@
1
+ export type Role = "reconcile" | "gc";
2
+ export type Trigger = "start" | "update_end" | "web_open" | "doctor" | "work_event";
3
+ export type Confirmation = "auto" | "operator" | "operator_via_main";
4
+ export type Reversibility = "trash" | "state_reopen" | "process_none" | "irreversible";
5
+ export interface Candidate { id: string; collector: string; target: string; reason: string; ageMs: number | null; bytes: number | null; details?: Record<string, unknown> }
6
+ export type Verdict = { kind: "keep"; why: string } | { kind: "act"; why: string; evidence: Record<string, unknown> } | { kind: "confirm"; why: string; evidence: Record<string, unknown> };
7
+ export interface ActResult { ok: boolean; method: "trash" | "deleted" | "sigterm" | "state" | "docker_rmi" | "git_prune"; error?: string; why?: string }
8
+ export interface Collector<D> {
9
+ readonly name: string;
10
+ readonly role: Role;
11
+ readonly triggers: readonly Trigger[];
12
+ readonly confirmation: Confirmation;
13
+ readonly reversibility: Reversibility;
14
+ /** Read only. */
15
+ find(deps: D): Promise<Candidate[]>;
16
+ /** Safety rules; any unreadable input -> keep. */
17
+ judge(c: Candidate, deps: D): Promise<Verdict>;
18
+ act(c: Candidate, deps: D): Promise<ActResult>;
19
+ }
20
+
21
+ /** A collector with its dependencies applied, as the engine runs it. */
22
+ export interface BoundCollector {
23
+ readonly name: string;
24
+ readonly role: Role;
25
+ readonly triggers: readonly Trigger[];
26
+ readonly confirmation: Confirmation;
27
+ readonly reversibility: Reversibility;
28
+ find(): Promise<Candidate[]>;
29
+ judge(c: Candidate): Promise<Verdict>;
30
+ act(c: Candidate): Promise<ActResult>;
31
+ }