@kawacode/mcp 6.1.5 → 6.8.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 (69) hide show
  1. package/CLAUDE.md.example +13 -0
  2. package/build/index.js +13 -1
  3. package/build/index.js.map +1 -1
  4. package/build/kawacode-on-pre-edit.d.ts +5 -0
  5. package/build/kawacode-on-pre-edit.js +73 -9
  6. package/build/kawacode-on-pre-edit.js.map +1 -1
  7. package/build/kawacode-on-stop.d.ts +49 -23
  8. package/build/kawacode-on-stop.js +288 -38
  9. package/build/kawacode-on-stop.js.map +1 -1
  10. package/build/services/muninn-ipc.d.ts +19 -1
  11. package/build/services/muninn-ipc.js +20 -2
  12. package/build/services/muninn-ipc.js.map +1 -1
  13. package/build/stop/uncompleted-commit.d.ts +63 -0
  14. package/build/stop/uncompleted-commit.js +188 -0
  15. package/build/stop/uncompleted-commit.js.map +1 -0
  16. package/build/stop/uncompleted-commit.test.d.ts +1 -0
  17. package/build/stop/uncompleted-commit.test.js +135 -0
  18. package/build/stop/uncompleted-commit.test.js.map +1 -0
  19. package/build/telemetry.d.ts +54 -0
  20. package/build/telemetry.js +84 -0
  21. package/build/telemetry.js.map +1 -0
  22. package/build/tools/activate-intent.d.ts +1 -14
  23. package/build/tools/activate-intent.js +17 -56
  24. package/build/tools/activate-intent.js.map +1 -1
  25. package/build/tools/arbiter-apply.d.ts +132 -0
  26. package/build/tools/arbiter-apply.js +59 -0
  27. package/build/tools/arbiter-apply.js.map +1 -0
  28. package/build/tools/arbiter-resolve.d.ts +132 -0
  29. package/build/tools/arbiter-resolve.js +58 -0
  30. package/build/tools/arbiter-resolve.js.map +1 -0
  31. package/build/tools/check-active-intent.d.ts +21 -12
  32. package/build/tools/check-active-intent.js +54 -27
  33. package/build/tools/check-active-intent.js.map +1 -1
  34. package/build/tools/complete-intent.d.ts +43 -10
  35. package/build/tools/complete-intent.js +51 -84
  36. package/build/tools/complete-intent.js.map +1 -1
  37. package/build/tools/create-intent.d.ts +1 -21
  38. package/build/tools/create-intent.js +18 -106
  39. package/build/tools/create-intent.js.map +1 -1
  40. package/build/tools/get-decision-detail.d.ts +109 -0
  41. package/build/tools/get-decision-detail.js +57 -0
  42. package/build/tools/get-decision-detail.js.map +1 -0
  43. package/build/tools/get-project-decisions.d.ts +0 -4
  44. package/build/tools/get-project-decisions.js +4 -6
  45. package/build/tools/get-project-decisions.js.map +1 -1
  46. package/build/tools/get-relevant-context.d.ts +0 -1
  47. package/build/tools/get-relevant-context.js +18 -3
  48. package/build/tools/get-relevant-context.js.map +1 -1
  49. package/build/tools/get-resolution-context.d.ts +154 -0
  50. package/build/tools/get-resolution-context.js +78 -0
  51. package/build/tools/get-resolution-context.js.map +1 -0
  52. package/build/tools/get-session-decisions.d.ts +0 -5
  53. package/build/tools/get-session-decisions.js +5 -5
  54. package/build/tools/get-session-decisions.js.map +1 -1
  55. package/build/tools/index.d.ts +216 -7
  56. package/build/tools/index.js +13 -3
  57. package/build/tools/index.js.map +1 -1
  58. package/build/tools/list-team-intents.d.ts +6 -6
  59. package/build/tools/list-team-intents.js +2 -2
  60. package/build/tools/list-team-intents.js.map +1 -1
  61. package/build/tools/pre-edit-acknowledge.d.ts +12 -0
  62. package/build/tools/pre-edit-acknowledge.js +21 -0
  63. package/build/tools/pre-edit-acknowledge.js.map +1 -1
  64. package/build/tools/pre-edit-decision-check.js +2 -0
  65. package/build/tools/pre-edit-decision-check.js.map +1 -1
  66. package/build/tools/record-decision.d.ts +76 -0
  67. package/build/tools/record-decision.js +10 -0
  68. package/build/tools/record-decision.js.map +1 -1
  69. package/package.json +2 -2
@@ -6,12 +6,11 @@ export const activateIntentSchema = z.object({
6
6
  repoOrigin: z.string().optional().describe('Git remote origin URL. Auto-detected from repoPath via git if not provided.'),
7
7
  repoPath: z.string().describe('Local path to the repository root'),
8
8
  intentId: z.string().describe('The cloud ID (preferred) or local UUID of the existing intent to activate.'),
9
- force: z.boolean().optional().default(false).describe('Bypass the per-repo active-intent lock. Set to true after the user has reviewed the lock conflict and chosen to take over.'),
10
9
  ...forkFieldsExtensions,
11
10
  });
12
11
  export async function activateIntent(input) {
13
12
  const actualOrigin = resolveOrigin(input.repoOrigin, input.repoPath);
14
- // Check if there's already an active intent
13
+ // This session's current focus before the switch.
15
14
  const activeRes = await request('intent', 'get-active', { repoOrigin: actualOrigin });
16
15
  const previousActiveId = activeRes.intentId || activeRes.intent?.id || '';
17
16
  if (previousActiveId === input.intentId) {
@@ -20,88 +19,50 @@ export async function activateIntent(input) {
20
19
  intentId: input.intentId,
21
20
  action: 'already_active',
22
21
  previousActiveId,
23
- message: `Intent ${input.intentId.substring(0, 8)} is already active`,
22
+ message: `Intent ${input.intentId.substring(0, 8)} is already your current intent`,
24
23
  };
25
24
  }
26
- // Set the intent as active
27
- const setRes = await request('intent', 'set-active', {
25
+ // Move THIS session's `current` pointer to the target intent. Under the
26
+ // multi-active model (no lock) this never conflicts — other sessions keep
27
+ // their own current pointers, and the API holds the full active set.
28
+ await request('intent', 'set-active', {
28
29
  repoOrigin: actualOrigin,
29
30
  intentId: input.intentId,
30
- force: input.force || false,
31
31
  ...extractForkFields(input),
32
32
  });
33
- if (setRes.conflict === true && setRes.conflictType === 'active_intent_lock') {
34
- const lockConflict = await buildLockConflictDetails(actualOrigin, setRes.existingIntentId);
35
- const idShort = setRes.existingIntentId.substring(0, 8);
36
- const who = lockConflict.author ? ` by ${lockConflict.author}` : '';
37
- const titlePart = lockConflict.title ? ` "${lockConflict.title}"` : '';
38
- return {
39
- success: false,
40
- intentId: input.intentId,
41
- action: 'conflict',
42
- lockConflict,
43
- message: `Active-intent lock: repo already owns intent ${idShort}${titlePart}${who}. ` +
44
- `Call activate_intent again with force=true to take over, complete_intent on ${idShort} first, ` +
45
- `or choose a different intent.`,
46
- };
47
- }
48
33
  return {
49
34
  success: true,
50
35
  intentId: input.intentId,
51
36
  action: 'activated',
52
37
  previousActiveId: previousActiveId || undefined,
53
38
  message: previousActiveId
54
- ? `Activated intent ${input.intentId.substring(0, 8)} (was: ${previousActiveId.substring(0, 8)})`
39
+ ? `Switched current intent to ${input.intentId.substring(0, 8)} (was: ${previousActiveId.substring(0, 8)})`
55
40
  : `Activated intent ${input.intentId.substring(0, 8)}`,
56
41
  };
57
42
  }
58
- async function buildLockConflictDetails(repoOrigin, existingIntentId) {
59
- try {
60
- const res = await request('intent', 'get-active', { repoOrigin });
61
- const intent = res.intent;
62
- if (intent && intent.id === existingIntentId) {
63
- return {
64
- existingIntentId,
65
- title: intent.title,
66
- createdBy: intent.createdBy,
67
- author: intent.authorInfo?.name || intent.author,
68
- };
69
- }
70
- }
71
- catch {
72
- // Fall through to ID-only response
73
- }
74
- return { existingIntentId };
75
- }
76
43
  export const activateIntentTool = {
77
44
  name: 'activate_intent',
78
- description: `Activate an existing intent by ID without creating a new one.
45
+ description: `Activate an existing intent by ID — sets it as THIS session's current focus.
79
46
 
80
47
  Use this to:
81
- - Switch to a different intent found via list_team_intents or get_relevant_context
48
+ - Switch your current focus to a different intent found via list_team_intents or get_relevant_context
82
49
  - Re-activate an intent that was deactivated (e.g., to complete it)
83
50
  - Resume work on a previously created intent
84
- - Resume an "abandoned" or "pending" intent (see below)
51
+ - Resume an "abandoned" intent (see below)
85
52
 
86
53
  Accepts both cloud IDs (from get_relevant_context / API) and local UUIDs (from list_team_intents).
87
54
 
88
- Resuming abandoned / pending intents:
55
+ Multi-active model: activating an intent only moves YOUR session's current
56
+ pointer. Many intents can be active on a repo at once (one current per
57
+ session/teammate), so this never blocks on or displaces another session's
58
+ active intent — there is no lock to take over.
59
+
60
+ Resuming abandoned intents:
89
61
  - Abandoned intents have their decisions soft-deleted (invisible to recall and
90
62
  get_relevant_context). Activating one transparently restores them — single-intent
91
63
  decisions for this intent get their soft-delete cleared so the prior reasoning
92
64
  becomes visible again. Multi-intent decisions stay visible throughout (they were
93
- never soft-deleted).
94
- - Pending intents are intents auto-finalized by the orphan-recovery sweeper (24h
95
- inactivity) — possibly with conflicts blocking the finalization. Their decisions
96
- were never soft-deleted, so activating one is a clean resume; new ephemerals
97
- accumulate in a fresh bucket and the next complete_intent distills only the new work.
98
-
99
- Per-repo active-intent lock: if another session already has a different intent active on
100
- this repo, the tool returns action="conflict" with lockConflict details. Present the
101
- conflict to the user and choose one of:
102
- - Take over: retry with force=true (displaces the other session's active intent).
103
- - Complete first: call complete_intent on the existing intent, then retry.
104
- - Cancel: choose a different intent or stop.`,
65
+ never soft-deleted).`,
105
66
  inputSchema: activateIntentSchema,
106
67
  handler: activateIntent,
107
68
  };
@@ -1 +1 @@
1
- {"version":3,"file":"activate-intent.js","sourceRoot":"","sources":["../../src/tools/activate-intent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAE3E,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,6EAA6E,CAAC;IACzH,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,mCAAmC,CAAC;IAClE,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,4EAA4E,CAAC;IAC3G,KAAK,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,4HAA4H,CAAC;IACnL,GAAG,oBAAoB;CACxB,CAAC,CAAA;AAoBF,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,KAA0B;IAC7D,MAAM,YAAY,GAAG,aAAa,CAAC,KAAK,CAAC,U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 'zod';
2
+ export declare const arbiterApplySchema: z.ZodObject<{
3
+ forkAuthor: z.ZodOptional<z.ZodObject<{
4
+ platform: z.ZodEnum<["github", "gitlab"]>;
5
+ user: z.ZodString;
6
+ forkOrigin: z.ZodString;
7
+ }, "strip", z.ZodTypeAny, {
8
+ platform: "github" | "gitlab";
9
+ user: string;
10
+ forkOrigin: string;
11
+ }, {
12
+ platform: "github" | "gitlab";
13
+ user: string;
14
+ forkOrigin: string;
15
+ }>>;
16
+ workspaceId: z.ZodOptional<z.ZodString>;
17
+ repoPath: z.ZodString;
18
+ repoOrigin: z.ZodOptional<z.ZodString>;
19
+ intentId: z.ZodOptional<z.ZodString>;
20
+ overlaps: z.ZodArray<z.ZodObject<{
21
+ peerUid: z.ZodString;
22
+ filePath: z.ZodString;
23
+ ranges: z.ZodArray<z.ZodArray<z.ZodNumber, "many">, "many">;
24
+ }, "strip", z.ZodTypeAny, {
25
+ filePath: string;
26
+ peerUid: string;
27
+ ranges: number[][];
28
+ }, {
29
+ filePath: string;
30
+ peerUid: string;
31
+ ranges: number[][];
32
+ }>, "many">;
33
+ }, "strip", z.ZodTypeAny, {
34
+ repoPath: string;
35
+ overlaps: {
36
+ filePath: string;
37
+ peerUid: string;
38
+ ranges: number[][];
39
+ }[];
40
+ repoOrigin?: string | undefined;
41
+ forkAuthor?: {
42
+ platform: "github" | "gitlab";
43
+ user: string;
44
+ forkOrigin: string;
45
+ } | undefined;
46
+ workspaceId?: string | undefined;
47
+ intentId?: string | undefined;
48
+ }, {
49
+ repoPath: string;
50
+ overlaps: {
51
+ filePath: string;
52
+ peerUid: string;
53
+ ranges: number[][];
54
+ }[];
55
+ repoOrigin?: string | undefined;
56
+ forkAuthor?: {
57
+ platform: "github" | "gitlab";
58
+ user: string;
59
+ forkOrigin: string;
60
+ } | undefined;
61
+ workspaceId?: string | undefined;
62
+ intentId?: string | undefined;
63
+ }>;
64
+ export type ArbiterApplyInput = z.infer<typeof arbiterApplySchema>;
65
+ export declare function arbiterApply(input: ArbiterApplyInput): Promise<any>;
66
+ export declare const arbiterApplyTool: {
67
+ name: string;
68
+ description: string;
69
+ inputSchema: z.ZodObject<{
70
+ forkAuthor: z.ZodOptional<z.ZodObject<{
71
+ platform: z.ZodEnum<["github", "gitlab"]>;
72
+ user: z.ZodString;
73
+ forkOrigin: z.ZodString;
74
+ }, "strip", z.ZodTypeAny, {
75
+ platform: "github" | "gitlab";
76
+ user: string;
77
+ forkOrigin: string;
78
+ }, {
79
+ platform: "github" | "gitlab";
80
+ user: string;
81
+ forkOrigin: string;
82
+ }>>;
83
+ workspaceId: z.ZodOptional<z.ZodString>;
84
+ repoPath: z.ZodString;
85
+ repoOrigin: z.ZodOptional<z.ZodString>;
86
+ intentId: z.ZodOptional<z.ZodString>;
87
+ overlaps: z.ZodArray<z.ZodObject<{
88
+ peerUid: z.ZodString;
89
+ filePath: z.ZodString;
90
+ ranges: z.ZodArray<z.ZodArray<z.ZodNumber, "many">, "many">;
91
+ }, "strip", z.ZodTypeAny, {
92
+ filePath: string;
93
+ peerUid: string;
94
+ ranges: number[][];
95
+ }, {
96
+ filePath: string;
97
+ peerUid: string;
98
+ ranges: number[][];
99
+ }>, "many">;
100
+ }, "strip", z.ZodTypeAny, {
101
+ repoPath: string;
102
+ overlaps: {
103
+ filePath: string;
104
+ peerUid: string;
105
+ ranges: number[][];
106
+ }[];
107
+ repoOrigin?: string | undefined;
108
+ forkAuthor?: {
109
+ platform: "github" | "gitlab";
110
+ user: string;
111
+ forkOrigin: string;
112
+ } | undefined;
113
+ workspaceId?: string | undefined;
114
+ intentId?: string | undefined;
115
+ }, {
116
+ repoPath: string;
117
+ overlaps: {
118
+ filePath: string;
119
+ peerUid: string;
120
+ ranges: number[][];
121
+ }[];
122
+ repoOrigin?: string | undefined;
123
+ forkAuthor?: {
124
+ platform: "github" | "gitlab";
125
+ user: string;
126
+ forkOrigin: string;
127
+ } | undefined;
128
+ workspaceId?: string | undefined;
129
+ intentId?: string | undefined;
130
+ }>;
131
+ handler: typeof arbiterApply;
132
+ };
@@ -0,0 +1,59 @@
1
+ import { z } from 'zod';
2
+ import { request } from '../services/muninn-ipc.js';
3
+ import { resolveOrigin } from './resolve-origin.js';
4
+ import { forkFieldsExtensions, extractForkFields } from './_fork-fields.js';
5
+ /**
6
+ * arbiter_apply — thin forwarder to Muninn `arbiter:apply` (Arbiter v2).
7
+ * Judges → adversarially verifies → auto-applies only the trivial tier, and ONLY
8
+ * in an agent-owned worktree. All judgment/verify/write/republish lives in Muninn;
9
+ * this is a stateless adapter.
10
+ */
11
+ const overlapSchema = z.object({
12
+ peerUid: z
13
+ .string()
14
+ .describe('The peer HAI whose live edits overlap — a collision `uid` from the Stop report.'),
15
+ filePath: z.string().describe('File with the overlap, relative to repoPath.'),
16
+ ranges: z
17
+ .array(z.array(z.number()))
18
+ .describe('Overlapping [start, end] line ranges (cSHA line space) from the collision.'),
19
+ });
20
+ export const arbiterApplySchema = z.object({
21
+ repoPath: z.string().describe('Local path to the repository root'),
22
+ repoOrigin: z
23
+ .string()
24
+ .optional()
25
+ .describe('Git remote origin URL. Auto-detected from repoPath via git if not provided.'),
26
+ intentId: z
27
+ .string()
28
+ .optional()
29
+ .describe('Active intent ID (advisory; the auto-resolution decision is recorded under it).'),
30
+ overlaps: z
31
+ .array(overlapSchema)
32
+ .describe('The overlaps to resolve — each { peerUid, filePath, ranges } from the Stop collision report.'),
33
+ ...forkFieldsExtensions,
34
+ });
35
+ export async function arbiterApply(input) {
36
+ const repoOrigin = resolveOrigin(input.repoOrigin, input.repoPath);
37
+ const res = await request('arbiter', 'apply', {
38
+ repoOrigin,
39
+ repoPath: input.repoPath,
40
+ intentId: input.intentId,
41
+ overlaps: input.overlaps,
42
+ ...extractForkFields(input),
43
+ });
44
+ return res;
45
+ }
46
+ export const arbiterApplyTool = {
47
+ name: 'arbiter_apply',
48
+ description: 'Resolve live code overlaps and AUTO-APPLY the safe tier. Kawa judges → adversarially verifies → and, ' +
49
+ 'for the trivial tier only (high-confidence single-range merge that passes verify), writes the merge to ' +
50
+ 'your worktree, records a decision, and republishes. Writes happen ONLY in an agent-owned worktree (a ' +
51
+ 'linked git worktree); on a human checkout — or when a peer holds the file-set lock — it behaves like ' +
52
+ 'arbiter_resolve (suggest-only, no writes). Returns per-overlap outcomes { tier, applied, announcement, ' +
53
+ 'verifyIssue?, verdict }. Call it when you are ready to incorporate the result, then RE-READ any file it ' +
54
+ 'applied to (it changed on disk). For surfaced (not-applied) overlaps, use get_resolution_context to see ' +
55
+ 'the peer code and resolve manually.',
56
+ inputSchema: arbiterApplySchema,
57
+ handler: arbiterApply,
58
+ };
59
+ //# sourceMappingURL=arbiter-apply.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arbiter-apply.js","sourceRoot":"","sources":["../../src/tools/arbiter-apply.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAE3E;;;;;GAKG;AACH,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7B,OAAO,EAAE,CAAC;SACP,MAAM,EAAE;SACR,QAAQ,CAAC,iFAAiF,CAAC;IAC9F,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,8CAA8C,CAAC;IAC7E,MAAM,EAAE,CAAC;SACN,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;SAC1B,QAAQ,CAAC,4EAA4E,CAAC;CAC1F,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,mCAAmC,CAAC;IAClE,UAAU,EAAE,CAAC;SACV,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CAAC,6EAA6E,CAAC;IAC1F,QAAQ,EAAE,CAAC;SACR,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CAAC,iFAAiF,CAAC;IAC9F,QAAQ,EAAE,CAAC;SACR,KAAK,CAAC,aAAa,CAAC;SACpB,QAAQ,CAAC,8FAA8F,CAAC;IAC3G,GAAG,oBAAoB;CACxB,CAAC,CAAA;AAIF,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,KAAwB;IACzD,MAAM,UAAU,GAAG,aAAa,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAA;IAClE,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,SAAS,EAAE,OAAO,EAAE;QAC5C,UAAU;QACV,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,GAAG,iBAAiB,CAAC,KAAK,CAAC;KAC5B,CAAC,CAAA;IACF,OAAO,GAAG,CAAA;AACZ,CAAC;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,IAAI,EAAE,eAAe;IACrB,WAAW,EACT,uGAAuG;QACvG,yGAAyG;QACzG,uGAAuG;QACvG,uGAAuG;QACvG,yGAAyG;QACzG,0GAA0G;QAC1G,0GAA0G;QAC1G,qCAAqC;IACvC,WAAW,EAAE,kBAAkB;IAC/B,OAAO,EAAE,YAAY;CACtB,CAAA"}
@@ -0,0 +1,132 @@
1
+ import { z } from 'zod';
2
+ export declare const arbiterResolveSchema: z.ZodObject<{
3
+ forkAuthor: z.ZodOptional<z.ZodObject<{
4
+ platform: z.ZodEnum<["github", "gitlab"]>;
5
+ user: z.ZodString;
6
+ forkOrigin: z.ZodString;
7
+ }, "strip", z.ZodTypeAny, {
8
+ platform: "github" | "gitlab";
9
+ user: string;
10
+ forkOrigin: string;
11
+ }, {
12
+ platform: "github" | "gitlab";
13
+ user: string;
14
+ forkOrigin: string;
15
+ }>>;
16
+ workspaceId: z.ZodOptional<z.ZodString>;
17
+ repoPath: z.ZodString;
18
+ repoOrigin: z.ZodOptional<z.ZodString>;
19
+ intentId: z.ZodOptional<z.ZodString>;
20
+ overlaps: z.ZodArray<z.ZodObject<{
21
+ peerUid: z.ZodString;
22
+ filePath: z.ZodString;
23
+ ranges: z.ZodArray<z.ZodArray<z.ZodNumber, "many">, "many">;
24
+ }, "strip", z.ZodTypeAny, {
25
+ filePath: string;
26
+ peerUid: string;
27
+ ranges: number[][];
28
+ }, {
29
+ filePath: string;
30
+ peerUid: string;
31
+ ranges: number[][];
32
+ }>, "many">;
33
+ }, "strip", z.ZodTypeAny, {
34
+ repoPath: string;
35
+ overlaps: {
36
+ filePath: string;
37
+ peerUid: string;
38
+ ranges: number[][];
39
+ }[];
40
+ repoOrigin?: string | undefined;
41
+ forkAuthor?: {
42
+ platform: "github" | "gitlab";
43
+ user: string;
44
+ forkOrigin: string;
45
+ } | undefined;
46
+ workspaceId?: string | undefined;
47
+ intentId?: string | undefined;
48
+ }, {
49
+ repoPath: string;
50
+ overlaps: {
51
+ filePath: string;
52
+ peerUid: string;
53
+ ranges: number[][];
54
+ }[];
55
+ repoOrigin?: string | undefined;
56
+ forkAuthor?: {
57
+ platform: "github" | "gitlab";
58
+ user: string;
59
+ forkOrigin: string;
60
+ } | undefined;
61
+ workspaceId?: string | undefined;
62
+ intentId?: string | undefined;
63
+ }>;
64
+ export type ArbiterResolveInput = z.infer<typeof arbiterResolveSchema>;
65
+ export declare function arbiterResolve(input: ArbiterResolveInput): Promise<any>;
66
+ export declare const arbiterResolveTool: {
67
+ name: string;
68
+ description: string;
69
+ inputSchema: z.ZodObject<{
70
+ forkAuthor: z.ZodOptional<z.ZodObject<{
71
+ platform: z.ZodEnum<["github", "gitlab"]>;
72
+ user: z.ZodString;
73
+ forkOrigin: z.ZodString;
74
+ }, "strip", z.ZodTypeAny, {
75
+ platform: "github" | "gitlab";
76
+ user: string;
77
+ forkOrigin: string;
78
+ }, {
79
+ platform: "github" | "gitlab";
80
+ user: string;
81
+ forkOrigin: string;
82
+ }>>;
83
+ workspaceId: z.ZodOptional<z.ZodString>;
84
+ repoPath: z.ZodString;
85
+ repoOrigin: z.ZodOptional<z.ZodString>;
86
+ intentId: z.ZodOptional<z.ZodString>;
87
+ overlaps: z.ZodArray<z.ZodObject<{
88
+ peerUid: z.ZodString;
89
+ filePath: z.ZodString;
90
+ ranges: z.ZodArray<z.ZodArray<z.ZodNumber, "many">, "many">;
91
+ }, "strip", z.ZodTypeAny, {
92
+ filePath: string;
93
+ peerUid: string;
94
+ ranges: number[][];
95
+ }, {
96
+ filePath: string;
97
+ peerUid: string;
98
+ ranges: number[][];
99
+ }>, "many">;
100
+ }, "strip", z.ZodTypeAny, {
101
+ repoPath: string;
102
+ overlaps: {
103
+ filePath: string;
104
+ peerUid: string;
105
+ ranges: number[][];
106
+ }[];
107
+ repoOrigin?: string | undefined;
108
+ forkAuthor?: {
109
+ platform: "github" | "gitlab";
110
+ user: string;
111
+ forkOrigin: string;
112
+ } | undefined;
113
+ workspaceId?: string | undefined;
114
+ intentId?: string | undefined;
115
+ }, {
116
+ repoPath: string;
117
+ overlaps: {
118
+ filePath: string;
119
+ peerUid: string;
120
+ ranges: number[][];
121
+ }[];
122
+ repoOrigin?: string | undefined;
123
+ forkAuthor?: {
124
+ platform: "github" | "gitlab";
125
+ user: string;
126
+ forkOrigin: string;
127
+ } | undefined;
128
+ workspaceId?: string | undefined;
129
+ intentId?: string | undefined;
130
+ }>;
131
+ handler: typeof arbiterResolve;
132
+ };
@@ -0,0 +1,58 @@
1
+ import { z } from 'zod';
2
+ import { request } from '../services/muninn-ipc.js';
3
+ import { resolveOrigin } from './resolve-origin.js';
4
+ import { forkFieldsExtensions, extractForkFields } from './_fork-fields.js';
5
+ /**
6
+ * arbiter_resolve — thin forwarder to Muninn `arbiter:resolve` (Arbiter v2).
7
+ * Suggest-only: judges live code overlaps with peers and returns verdicts; never
8
+ * writes. All decrypt + judgment lives in Muninn (zero-knowledge); this is a
9
+ * stateless adapter.
10
+ */
11
+ const overlapSchema = z.object({
12
+ peerUid: z
13
+ .string()
14
+ .describe('The peer HAI whose live edits overlap — a collision `uid` from the Stop report.'),
15
+ filePath: z.string().describe('File with the overlap, relative to repoPath.'),
16
+ ranges: z
17
+ .array(z.array(z.number()))
18
+ .describe('Overlapping [start, end] line ranges (cSHA line space) from the collision.'),
19
+ });
20
+ export const arbiterResolveSchema = z.object({
21
+ repoPath: z.string().describe('Local path to the repository root'),
22
+ repoOrigin: z
23
+ .string()
24
+ .optional()
25
+ .describe('Git remote origin URL. Auto-detected from repoPath via git if not provided.'),
26
+ intentId: z
27
+ .string()
28
+ .optional()
29
+ .describe('Active intent ID (advisory). Auto-detected by Kawa Code when omitted.'),
30
+ overlaps: z
31
+ .array(overlapSchema)
32
+ .describe('The overlaps to judge — each { peerUid, filePath, ranges } from the Stop collision report.'),
33
+ ...forkFieldsExtensions,
34
+ });
35
+ export async function arbiterResolve(input) {
36
+ const repoOrigin = resolveOrigin(input.repoOrigin, input.repoPath);
37
+ const res = await request('arbiter', 'resolve', {
38
+ repoOrigin,
39
+ repoPath: input.repoPath,
40
+ intentId: input.intentId,
41
+ overlaps: input.overlaps,
42
+ ...extractForkFields(input),
43
+ });
44
+ return res;
45
+ }
46
+ export const arbiterResolveTool = {
47
+ name: 'arbiter_resolve',
48
+ description: 'Get Kawa Code\'s AI verdict for live code overlaps with peers — SUGGEST-ONLY, never writes. ' +
49
+ 'For each overlap ({peerUid, filePath, ranges} from the Stop collision report), Kawa decrypts the ' +
50
+ "peer's version locally (zero-knowledge) and judges it compatible / auto_resolvable / conflict, with " +
51
+ 'confidence, a perf/security risk read, and a tier (0 no-op · 1 trivially auto-appliable · 2 ' +
52
+ 'draft-and-confirm · 3 conflict). Use it to understand a forming conflict before acting. For a ' +
53
+ 'surfaced tier-2/3 overlap, call get_resolution_context to read the peer\'s actual code. To actually ' +
54
+ 'apply the safe tier, use arbiter_apply.',
55
+ inputSchema: arbiterResolveSchema,
56
+ handler: arbiterResolve,
57
+ };
58
+ //# sourceMappingURL=arbiter-resolve.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arbiter-resolve.js","sourceRoot":"","sources":["../../src/tools/arbiter-resolve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAE3E;;;;;GAKG;AACH,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7B,OAAO,EAAE,CAAC;SACP,MAAM,EAAE;SACR,QAAQ,CAAC,iFAAiF,CAAC;IAC9F,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,8CAA8C,CAAC;IAC7E,MAAM,EAAE,CAAC;SACN,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;SAC1B,QAAQ,CAAC,4EAA4E,CAAC;CAC1F,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,mCAAmC,CAAC;IAClE,UAAU,EAAE,CAAC;SACV,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CAAC,6EAA6E,CAAC;IAC1F,QAAQ,EAAE,CAAC;SACR,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CAAC,uEAAuE,CAAC;IACpF,QAAQ,EAAE,CAAC;SACR,KAAK,CAAC,aAAa,CAAC;SACpB,QAAQ,CAAC,4FAA4F,CAAC;IACzG,GAAG,oBAAoB;CACxB,CAAC,CAAA;AAIF,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,KAA0B;IAC7D,MAAM,UAAU,GAAG,aAAa,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAA;IAClE,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,SAAS,EAAE,SAAS,EAAE;QAC9C,UAAU;QACV,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,GAAG,iBAAiB,CAAC,KAAK,CAAC;KAC5B,CAAC,CAAA;IACF,OAAO,GAAG,CAAA;AACZ,CAAC;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,IAAI,EAAE,iBAAiB;IACvB,WAAW,EACT,8FAA8F;QAC9F,mGAAmG;QACnG,sGAAsG;QACtG,8FAA8F;QAC9F,gGAAgG;QAChG,sGAAsG;QACtG,yCAAyC;IAC3C,WAAW,EAAE,oBAAoB;IACjC,OAAO,EAAE,cAAc;CACxB,CAAA"}
@@ -43,27 +43,36 @@ export interface IntentBlock {
43
43
  endLine: number;
44
44
  contentSnippet: string;
45
45
  }
46
+ /**
47
+ * One entry in the repo's active set. Under the multi-active model many intents
48
+ * can be `status:active` at once (one focus per session/teammate); this is a
49
+ * lightweight summary for the orchestration view, distinct from the calling
50
+ * session's own `current` intent (the top-level `intent`).
51
+ */
52
+ export interface ActiveIntentSummary {
53
+ id: string;
54
+ title: string;
55
+ status: string;
56
+ createdBy?: string;
57
+ author?: string;
58
+ }
46
59
  export interface ActiveIntentResponse {
47
60
  hasActiveIntent: boolean;
61
+ /**
62
+ * The repo's full active set — every session/teammate's currently-active
63
+ * intent — for orchestration/awareness. Independent of `hasActiveIntent`,
64
+ * which reports only whether THIS session has a current focus.
65
+ */
66
+ activeIntents?: ActiveIntentSummary[];
48
67
  intent?: {
49
68
  id: string;
50
69
  title: string;
51
70
  description: string;
52
71
  templateType: 'feature' | 'refactor' | 'exploration';
53
72
  constraints: string[];
54
- /**
55
- * `active` — currently being worked on (default).
56
- * `pending` — auto-finalized by the sweeper or blocked at completion by
57
- * conflicts; reportable as "live context" so the agent can prompt the
58
- * user to resume via activate_intent or finalize via complete_intent.
59
- */
73
+ /** `active` — currently being worked on (default). Terminal states:
74
+ * committed/pushed/done/abandoned/superseded. */
60
75
  status: string;
61
- /**
62
- * Set when status === 'pending'. One of `sweeper-auto-finalize` (24h
63
- * inactivity, no conflicts) or `sweeper-blocked-conflicts` (24h
64
- * inactivity, distilled decisions contradicted standards).
65
- */
66
- pendingReason?: string;
67
76
  branch: string;
68
77
  forkedFrom?: string;
69
78
  blocks: IntentBlock[];