@xenosystem/agent-interface-core 0.1.3

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 (122) hide show
  1. package/LICENSE +67 -0
  2. package/dist/agentDiscovery.d.ts +97 -0
  3. package/dist/agentDiscovery.d.ts.map +1 -0
  4. package/dist/agentDiscovery.js +93 -0
  5. package/dist/agentDiscovery.js.map +1 -0
  6. package/dist/capabilityRouting.d.ts +72 -0
  7. package/dist/capabilityRouting.d.ts.map +1 -0
  8. package/dist/capabilityRouting.js +124 -0
  9. package/dist/capabilityRouting.js.map +1 -0
  10. package/dist/capabilityTier.d.ts +105 -0
  11. package/dist/capabilityTier.d.ts.map +1 -0
  12. package/dist/capabilityTier.js +120 -0
  13. package/dist/capabilityTier.js.map +1 -0
  14. package/dist/combinationVerification.d.ts +101 -0
  15. package/dist/combinationVerification.d.ts.map +1 -0
  16. package/dist/combinationVerification.js +115 -0
  17. package/dist/combinationVerification.js.map +1 -0
  18. package/dist/context/agentAttachedContextPrompt.d.ts +13 -0
  19. package/dist/context/agentAttachedContextPrompt.d.ts.map +1 -0
  20. package/dist/context/agentAttachedContextPrompt.js +50 -0
  21. package/dist/context/agentAttachedContextPrompt.js.map +1 -0
  22. package/dist/context/agentModelContext.d.ts +77 -0
  23. package/dist/context/agentModelContext.d.ts.map +1 -0
  24. package/dist/context/agentModelContext.js +297 -0
  25. package/dist/context/agentModelContext.js.map +1 -0
  26. package/dist/fanOutPlanner.d.ts +65 -0
  27. package/dist/fanOutPlanner.d.ts.map +1 -0
  28. package/dist/fanOutPlanner.js +78 -0
  29. package/dist/fanOutPlanner.js.map +1 -0
  30. package/dist/fleetBoardProjection.d.ts +143 -0
  31. package/dist/fleetBoardProjection.d.ts.map +1 -0
  32. package/dist/fleetBoardProjection.js +156 -0
  33. package/dist/fleetBoardProjection.js.map +1 -0
  34. package/dist/fleetProjection.d.ts +63 -0
  35. package/dist/fleetProjection.d.ts.map +1 -0
  36. package/dist/fleetProjection.js +86 -0
  37. package/dist/fleetProjection.js.map +1 -0
  38. package/dist/hostBackedCapabilities.d.ts +50 -0
  39. package/dist/hostBackedCapabilities.d.ts.map +1 -0
  40. package/dist/hostBackedCapabilities.js +66 -0
  41. package/dist/hostBackedCapabilities.js.map +1 -0
  42. package/dist/index.d.ts +54 -0
  43. package/dist/index.d.ts.map +1 -0
  44. package/dist/index.js +134 -0
  45. package/dist/index.js.map +1 -0
  46. package/dist/intakeBoardProjection.d.ts +75 -0
  47. package/dist/intakeBoardProjection.d.ts.map +1 -0
  48. package/dist/intakeBoardProjection.js +90 -0
  49. package/dist/intakeBoardProjection.js.map +1 -0
  50. package/dist/intakeClaim.d.ts +156 -0
  51. package/dist/intakeClaim.d.ts.map +1 -0
  52. package/dist/intakeClaim.js +190 -0
  53. package/dist/intakeClaim.js.map +1 -0
  54. package/dist/knowledgeBoardProjection.d.ts +57 -0
  55. package/dist/knowledgeBoardProjection.d.ts.map +1 -0
  56. package/dist/knowledgeBoardProjection.js +74 -0
  57. package/dist/knowledgeBoardProjection.js.map +1 -0
  58. package/dist/landingOverlap.d.ts +127 -0
  59. package/dist/landingOverlap.d.ts.map +1 -0
  60. package/dist/landingOverlap.js +107 -0
  61. package/dist/landingOverlap.js.map +1 -0
  62. package/dist/landingQueue.d.ts +152 -0
  63. package/dist/landingQueue.d.ts.map +1 -0
  64. package/dist/landingQueue.js +258 -0
  65. package/dist/landingQueue.js.map +1 -0
  66. package/dist/markdown/markdownWindowsPaths.d.ts +20 -0
  67. package/dist/markdown/markdownWindowsPaths.d.ts.map +1 -0
  68. package/dist/markdown/markdownWindowsPaths.js +208 -0
  69. package/dist/markdown/markdownWindowsPaths.js.map +1 -0
  70. package/dist/reviewProjection.d.ts +118 -0
  71. package/dist/reviewProjection.d.ts.map +1 -0
  72. package/dist/reviewProjection.js +133 -0
  73. package/dist/reviewProjection.js.map +1 -0
  74. package/dist/runDiff.d.ts +86 -0
  75. package/dist/runDiff.d.ts.map +1 -0
  76. package/dist/runDiff.js +103 -0
  77. package/dist/runDiff.js.map +1 -0
  78. package/dist/runtime/agentReasoningEffort.d.ts +22 -0
  79. package/dist/runtime/agentReasoningEffort.d.ts.map +1 -0
  80. package/dist/runtime/agentReasoningEffort.js +76 -0
  81. package/dist/runtime/agentReasoningEffort.js.map +1 -0
  82. package/dist/runtime/agentRuntimeProvider.d.ts +12 -0
  83. package/dist/runtime/agentRuntimeProvider.d.ts.map +1 -0
  84. package/dist/runtime/agentRuntimeProvider.js +294 -0
  85. package/dist/runtime/agentRuntimeProvider.js.map +1 -0
  86. package/dist/runtime/agentRuntimeProviderTypes.d.ts +100 -0
  87. package/dist/runtime/agentRuntimeProviderTypes.d.ts.map +1 -0
  88. package/dist/runtime/agentRuntimeProviderTypes.js +2 -0
  89. package/dist/runtime/agentRuntimeProviderTypes.js.map +1 -0
  90. package/dist/runtime/conversationRuntime.d.ts +53 -0
  91. package/dist/runtime/conversationRuntime.d.ts.map +1 -0
  92. package/dist/runtime/conversationRuntime.js +207 -0
  93. package/dist/runtime/conversationRuntime.js.map +1 -0
  94. package/dist/runtime/legacyAgentRuntimeEvents.d.ts +65 -0
  95. package/dist/runtime/legacyAgentRuntimeEvents.d.ts.map +1 -0
  96. package/dist/runtime/legacyAgentRuntimeEvents.js +104 -0
  97. package/dist/runtime/legacyAgentRuntimeEvents.js.map +1 -0
  98. package/dist/runtimeProjection.d.ts +19 -0
  99. package/dist/runtimeProjection.d.ts.map +1 -0
  100. package/dist/runtimeProjection.js +133 -0
  101. package/dist/runtimeProjection.js.map +1 -0
  102. package/dist/sessionBoardProjection.d.ts +84 -0
  103. package/dist/sessionBoardProjection.d.ts.map +1 -0
  104. package/dist/sessionBoardProjection.js +103 -0
  105. package/dist/sessionBoardProjection.js.map +1 -0
  106. package/dist/sessionMode.d.ts +115 -0
  107. package/dist/sessionMode.d.ts.map +1 -0
  108. package/dist/sessionMode.js +98 -0
  109. package/dist/sessionMode.js.map +1 -0
  110. package/dist/workspace/workspaceSelectionContinuation.d.ts +8 -0
  111. package/dist/workspace/workspaceSelectionContinuation.d.ts.map +1 -0
  112. package/dist/workspace/workspaceSelectionContinuation.js +18 -0
  113. package/dist/workspace/workspaceSelectionContinuation.js.map +1 -0
  114. package/dist/workspaceKnowledge.d.ts +90 -0
  115. package/dist/workspaceKnowledge.d.ts.map +1 -0
  116. package/dist/workspaceKnowledge.js +103 -0
  117. package/dist/workspaceKnowledge.js.map +1 -0
  118. package/dist/writeLease.d.ts +92 -0
  119. package/dist/writeLease.d.ts.map +1 -0
  120. package/dist/writeLease.js +108 -0
  121. package/dist/writeLease.js.map +1 -0
  122. package/package.json +29 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,GAM3B,MAAM,sCAAsC,CAAA;AAE7C,cAAc,wBAAwB,CAAA;AACtC,cAAc,sBAAsB,CAAA;AACpC,cAAc,2BAA2B,CAAA;AACzC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,kBAAkB,CAAA;AAChC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,yBAAyB,CAAA;AACvC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,qBAAqB,CAAA;AACnC,cAAc,mBAAmB,CAAA;AACjC,cAAc,uBAAuB,CAAA;AACrC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,yCAAyC,CAAA;AACvD,cAAc,gCAAgC,CAAA;AAC9C,cAAc,oCAAoC,CAAA;AAClD,cAAc,mCAAmC,CAAA;AACjD,cAAc,mCAAmC,CAAA;AACjD,cAAc,wCAAwC,CAAA;AACtD,cAAc,kCAAkC,CAAA;AAChD,cAAc,uCAAuC,CAAA;AACrD,cAAc,+CAA+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YACnD,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,IAAI,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAClF,CAAC;KACH,CAAA;AACH,CAAC;AAED,SAAS,aAAa,CAAC,KAAuD;IAC5E,OAAO,KAAK,CAAC,YAAY,KAAK,WAAW,IAAI,KAAK,CAAC,YAAY,KAAK,UAAU,CAAA;AAChF,CAAC;AACD,cAAc,wBAAwB,CAAA;AACtC,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA"}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * What an intake surface may SHOW โ€” ADE ยง5.1, the presentation half.
3
+ *
4
+ * `intake.items.list` answers what is in the inbox; this decides what a person
5
+ * is told about each item's availability and what they may do about it. Pure, in
6
+ * `core`, for the same reason the review, fleet and session projections are.
7
+ *
8
+ * ## ๐Ÿ”ด Availability has FOUR states, and collapsing any two misleads
9
+ *
10
+ * `free` โ€” nobody has it, take it.
11
+ * `mine` โ€” you hold it, so finish or hand it back.
12
+ * `theirs` โ€” someone else holds it; your claim will be refused and you should
13
+ * pick something else.
14
+ * `dispatched` โ€” a run is already doing it; go look at the run, do not re-do it.
15
+ *
16
+ * A board that renders `theirs` like `free` invites a claim that will fail. One
17
+ * that renders `dispatched` like `theirs` sends someone to negotiate with a
18
+ * colleague over work a machine is already finishing.
19
+ *
20
+ * ## An incomplete inbox is not a short inbox
21
+ *
22
+ * If a tracker failed, the list is missing work โ€” and "missing work" reads as
23
+ * "no more work". The notice is first, for the same reason the fleet board's is.
24
+ */
25
+ export interface IntakeBoardItemInput {
26
+ id: string;
27
+ sourceId: string;
28
+ externalId: string;
29
+ title: string;
30
+ detail?: string;
31
+ createdAt?: number;
32
+ url?: string;
33
+ claimState: string;
34
+ claimedBy?: string;
35
+ runId?: string;
36
+ }
37
+ export interface IntakeBoardInput {
38
+ available: boolean;
39
+ items: IntakeBoardItemInput[];
40
+ complete: boolean;
41
+ failedSources: Array<{
42
+ sourceId: string;
43
+ problem: string;
44
+ }>;
45
+ reason?: string;
46
+ }
47
+ export type IntakeAvailability = 'free' | 'mine' | 'theirs' | 'dispatched';
48
+ export interface IntakeBoardRow {
49
+ id: string;
50
+ sourceId: string;
51
+ title: string;
52
+ detail?: string;
53
+ url?: string;
54
+ availability: IntakeAvailability;
55
+ /** Who holds it, when someone else does. Named, never "someone". */
56
+ heldBy?: string;
57
+ /** The run doing it, when dispatched โ€” so a person can go look rather than ask. */
58
+ runId?: string;
59
+ /** Advice for enabling a control. The host still arbitrates. */
60
+ canClaim: boolean;
61
+ canRelease: boolean;
62
+ canDispatch: boolean;
63
+ headline: string;
64
+ }
65
+ export interface IntakeBoard {
66
+ rows: IntakeBoardRow[];
67
+ /** How many items nobody has taken โ€” the number that answers "is there work?" */
68
+ freeCount: number;
69
+ /** Present when the inbox is not the whole picture, or cannot be read at all. */
70
+ notice?: string;
71
+ /** True only when every source answered. */
72
+ trustworthy: boolean;
73
+ }
74
+ export declare function projectIntakeBoard(input: IntakeBoardInput, clientId: string): IntakeBoard;
75
+ //# sourceMappingURL=intakeBoardProjection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intakeBoardProjection.d.ts","sourceRoot":"","sources":["../src/intakeBoardProjection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,CAAA;IACV,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,OAAO,CAAA;IAClB,KAAK,EAAE,oBAAoB,EAAE,CAAA;IAC7B,QAAQ,EAAE,OAAO,CAAA;IACjB,aAAa,EAAE,KAAK,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IAC3D,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,YAAY,CAAA;AAE1E,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAA;IACV,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,kBAAkB,CAAA;IAChC,oEAAoE;IACpE,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,mFAAmF;IACnF,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,gEAAgE;IAChE,QAAQ,EAAE,OAAO,CAAA;IACjB,UAAU,EAAE,OAAO,CAAA;IACnB,WAAW,EAAE,OAAO,CAAA;IACpB,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,cAAc,EAAE,CAAA;IACtB,iFAAiF;IACjF,SAAS,EAAE,MAAM,CAAA;IACjB,iFAAiF;IACjF,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,4CAA4C;IAC5C,WAAW,EAAE,OAAO,CAAA;CACrB;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,GAAG,WAAW,CAqCzF"}
@@ -0,0 +1,90 @@
1
+ /**
2
+ * What an intake surface may SHOW โ€” ADE ยง5.1, the presentation half.
3
+ *
4
+ * `intake.items.list` answers what is in the inbox; this decides what a person
5
+ * is told about each item's availability and what they may do about it. Pure, in
6
+ * `core`, for the same reason the review, fleet and session projections are.
7
+ *
8
+ * ## ๐Ÿ”ด Availability has FOUR states, and collapsing any two misleads
9
+ *
10
+ * `free` โ€” nobody has it, take it.
11
+ * `mine` โ€” you hold it, so finish or hand it back.
12
+ * `theirs` โ€” someone else holds it; your claim will be refused and you should
13
+ * pick something else.
14
+ * `dispatched` โ€” a run is already doing it; go look at the run, do not re-do it.
15
+ *
16
+ * A board that renders `theirs` like `free` invites a claim that will fail. One
17
+ * that renders `dispatched` like `theirs` sends someone to negotiate with a
18
+ * colleague over work a machine is already finishing.
19
+ *
20
+ * ## An incomplete inbox is not a short inbox
21
+ *
22
+ * If a tracker failed, the list is missing work โ€” and "missing work" reads as
23
+ * "no more work". The notice is first, for the same reason the fleet board's is.
24
+ */
25
+ export function projectIntakeBoard(input, clientId) {
26
+ if (!input.available) {
27
+ return {
28
+ rows: [],
29
+ freeCount: 0,
30
+ notice: input.reason ?? 'This host has no intake sources configured.',
31
+ // Not readable is not "no work". Nothing was measured.
32
+ trustworthy: false,
33
+ };
34
+ }
35
+ const rows = input.items.map((item) => {
36
+ const availability = availabilityFor(item, clientId);
37
+ return {
38
+ id: item.id,
39
+ sourceId: item.sourceId,
40
+ title: item.title,
41
+ ...(item.detail === undefined ? {} : { detail: item.detail }),
42
+ ...(item.url === undefined ? {} : { url: item.url }),
43
+ availability,
44
+ ...(availability === 'theirs' && item.claimedBy ? { heldBy: item.claimedBy } : {}),
45
+ ...(item.runId ? { runId: item.runId } : {}),
46
+ canClaim: availability === 'free',
47
+ // Only the holder may release or dispatch. Offering either on someone
48
+ // else's item produces a button whose only outcome is a refusal.
49
+ canRelease: availability === 'mine',
50
+ canDispatch: availability === 'mine',
51
+ headline: headlineFor(availability, item),
52
+ };
53
+ });
54
+ return {
55
+ rows,
56
+ freeCount: rows.filter((row) => row.availability === 'free').length,
57
+ ...(input.complete ? {} : { notice: noticeFor(input) }),
58
+ trustworthy: input.complete,
59
+ };
60
+ }
61
+ function availabilityFor(item, clientId) {
62
+ if (item.claimState === 'dispatched')
63
+ return 'dispatched';
64
+ if (item.claimState !== 'claimed')
65
+ return 'free';
66
+ return item.claimedBy === clientId ? 'mine' : 'theirs';
67
+ }
68
+ function headlineFor(availability, item) {
69
+ switch (availability) {
70
+ case 'free':
71
+ return 'Waiting to be picked up.';
72
+ case 'mine':
73
+ return 'Yours. Dispatch it to a run, or hand it back.';
74
+ case 'theirs':
75
+ return `${item.claimedBy} is on this.`;
76
+ case 'dispatched':
77
+ return `Being worked on by run ${item.runId}.`;
78
+ }
79
+ }
80
+ function noticeFor(input) {
81
+ const failed = input.failedSources;
82
+ if (failed.length === 0) {
83
+ return 'Some work could not be read, so this inbox may be missing items.';
84
+ }
85
+ // Sources NAMED, with the first reason. "Some sources failed" sends a person
86
+ // hunting; "jira did not answer" tells them where to look.
87
+ const names = failed.map((source) => source.sourceId).join(', ');
88
+ return `Could not read ${names}, so this inbox may be missing work โ€” ${failed[0]?.problem ?? 'no reason given'}.`;
89
+ }
90
+ //# sourceMappingURL=intakeBoardProjection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intakeBoardProjection.js","sourceRoot":"","sources":["../src/intakeBoardProjection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAqDH,MAAM,UAAU,kBAAkB,CAAC,KAAuB,EAAE,QAAgB;IAC1E,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC;QACrB,OAAO;YACL,IAAI,EAAE,EAAE;YACR,SAAS,EAAE,CAAC;YACZ,MAAM,EAAE,KAAK,CAAC,MAAM,IAAI,6CAA6C;YACrE,uDAAuD;YACvD,WAAW,EAAE,KAAK;SACnB,CAAA;IACH,CAAC;IAED,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAkB,EAAE;QACpD,MAAM,YAAY,GAAG,eAAe,CAAC,I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WAAW,EAAE,KAAK,CAAC,QAAQ;KAC5B,CAAA;AACH,CAAC;AAED,SAAS,eAAe,CAAC,IAA0B,EAAE,QAAgB;IACnE,IAAI,IAAI,CAAC,UAAU,KAAK,YAAY;QAAE,OAAO,YAAY,CAAA;IACzD,IAAI,IAAI,CAAC,UAAU,KAAK,SAAS;QAAE,OAAO,MAAM,CAAA;IAChD,OAAO,IAAI,CAAC,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAA;AACxD,CAAC;AAED,SAAS,WAAW,CAAC,YAAgC,EAAE,IAA0B;IAC/E,QAAQ,YAAY,EAAE,CAAC;QACrB,KAAK,MAAM;YACT,OAAO,0BAA0B,CAAA;QACnC,KAAK,MAAM;YACT,OAAO,+CAA+C,CAAA;QACxD,KAAK,QAAQ;YACX,OAAO,GAAG,IAAI,CAAC,SAAS,cAAc,CAAA;QACxC,KAAK,YAAY;YACf,OAAO,0BAA0B,IAAI,CAAC,KAAK,GAAG,CAAA;IAClD,CAAC;AACH,CAAC;AAED,SAAS,SAAS,CAAC,KAAuB;IACxC,MAAM,MAAM,GAAG,KAAK,CAAC,aAAa,CAAA;IAClC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO,kEAAkE,CAAA;IAC3E,CAAC;IACD,6EAA6E;IAC7E,2DAA2D;IAC3D,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAChE,OAAO,kBAAkB,KAAK,yCAAyC,MAAM,CAAC,CAAC,CAAC,EAAE,OAAO,IAAI,iBAAiB,GAAG,CAAA;AACnH,CAAC"}
@@ -0,0 +1,156 @@
1
+ /**
2
+ * Intake โ€” ADE ยง5.1, the first pillar of the developer's loop.
3
+ *
4
+ * Work arrives from everywhere: a typed instruction, a plan document, a TODO in
5
+ * the repository, an issue tracker, a scheduled trigger, another agent. This is
6
+ * the part that decides who gets to act on an item, and it is pure so that the
7
+ * one rule worth trusting can be tested without a tracker.
8
+ *
9
+ * ## ๐Ÿ”ด Claimed exactly once, under concurrent clients
10
+ *
11
+ * ยง5.1's gate. Two surfaces can be looking at the same queue, and two agents can
12
+ * be idle and eager. If both claim the same item, the same work is done twice โ€”
13
+ * and worse, both runs write to the same files, which is the merge-debt failure
14
+ * ยง5.7 exists to catch, arriving from the other end.
15
+ *
16
+ * A second claim is therefore REFUSED and told who holds it. Not queued, not
17
+ * silently re-granted: the caller needs to know it lost, because its next action
18
+ * (pick a different item) differs from the winner's.
19
+ *
20
+ * ## A source that FAILED is not a source with no work
21
+ *
22
+ * The same false-clean rule this codebase keeps re-learning. An unreachable
23
+ * tracker returning zero items looks exactly like a tracker with nothing to do,
24
+ * and an empty inbox reads as "nothing to pick up". So a failed source is
25
+ * reported as failed, and the aggregate says it is incomplete.
26
+ */
27
+ /** Where an item came from. Adapters implement one interface; a new tracker is
28
+ * configuration, never a code change here (ยง5.1 boundary). */
29
+ export interface IntakeSourceRef {
30
+ sourceId: string;
31
+ /** Stable id WITHIN that source โ€” an issue number, a file path, a line. */
32
+ externalId: string;
33
+ }
34
+ export interface IntakeItem {
35
+ /** Globally unique: `${sourceId}:${externalId}`. Derived, never supplied, so
36
+ * two sources cannot collide on a shared external id like "42". */
37
+ id: string;
38
+ source: IntakeSourceRef;
39
+ title: string;
40
+ /** Free text โ€” the body of an issue, the TODO line, the plan paragraph. */
41
+ detail?: string;
42
+ /** When the SOURCE says it was created, not when we saw it. */
43
+ createdAt?: number;
44
+ url?: string;
45
+ }
46
+ export declare function intakeItemId(source: IntakeSourceRef): string;
47
+ export type IntakeClaimState = {
48
+ state: 'unclaimed';
49
+ } | {
50
+ state: 'claimed';
51
+ byClientId: string;
52
+ at: number;
53
+ runId?: string;
54
+ } | {
55
+ state: 'dispatched';
56
+ byClientId: string;
57
+ at: number;
58
+ runId: string;
59
+ };
60
+ export type IntakeClaimResult = {
61
+ ok: true;
62
+ claim: Extract<IntakeClaimState, {
63
+ state: 'claimed';
64
+ }>;
65
+ } | {
66
+ ok: false;
67
+ code: 'already-claimed';
68
+ heldBy: string;
69
+ reason: string;
70
+ } | {
71
+ ok: false;
72
+ code: 'already-dispatched';
73
+ heldBy: string;
74
+ runId: string;
75
+ reason: string;
76
+ };
77
+ /**
78
+ * The claim registry.
79
+ *
80
+ * In-memory and single-process on purpose: the host IS the single authority for
81
+ * a user (ยง7), so this is where "exactly once" is decidable without a lock
82
+ * service. A detached host keeps that property โ€” it is one process by
83
+ * construction, which is the same reason the write lease lives there.
84
+ */
85
+ export declare class IntakeClaims {
86
+ #private;
87
+ constructor(options?: {
88
+ now?: () => number;
89
+ });
90
+ state(itemId: string): IntakeClaimState;
91
+ /**
92
+ * Takes an item for a client.
93
+ *
94
+ * ๐Ÿ”ด The second caller is REFUSED and told who won. Re-granting silently would
95
+ * put two runs on one item; queueing would leave a caller waiting for work it
96
+ * will never get. Losing is a fact it can act on.
97
+ */
98
+ claim(itemId: string, clientId: string): IntakeClaimResult;
99
+ /**
100
+ * Which item was dispatched to this run โ€” ยง5.1's provenance, asked the way a
101
+ * reviewer asks it.
102
+ *
103
+ * ๐Ÿ”ด The claim map answers "who is working on this ITEM". A person looking at
104
+ * a RUN asks the opposite question: "where did this work come from?" โ€” and a
105
+ * run whose origin cannot be recovered is one nobody can audit, which is what
106
+ * the gate's "dispatches to a run whose provenance records the source item"
107
+ * requires.
108
+ *
109
+ * Returns the FIRST match, because dispatch binds an item to a run once and
110
+ * refuses a second dispatch; returning a list would promise a fan-out the
111
+ * claim rules cannot produce.
112
+ */
113
+ dispatchedTo(runId: string): string | undefined;
114
+ /**
115
+ * Binds a claimed item to the run that will do it.
116
+ *
117
+ * Refuses unless the SAME client holds the claim โ€” dispatching someone else's
118
+ * item is how an item ends up worked twice with the registry showing one
119
+ * holder.
120
+ */
121
+ dispatch(itemId: string, clientId: string, runId: string): IntakeClaimResult;
122
+ /** Gives an item back. Only the holder may โ€” otherwise any client could free
123
+ * another's work and take it. */
124
+ release(itemId: string, clientId: string): boolean;
125
+ /** Every item this registry knows about, for a surface to render. */
126
+ entries(): Array<{
127
+ itemId: string;
128
+ state: IntakeClaimState;
129
+ }>;
130
+ }
131
+ export interface IntakeSourceResult {
132
+ sourceId: string;
133
+ items: IntakeItem[];
134
+ /** Present when the source could not be read. */
135
+ problem?: string;
136
+ }
137
+ export interface IntakeInbox {
138
+ items: Array<IntakeItem & {
139
+ claim: IntakeClaimState;
140
+ }>;
141
+ /** Sources that answered. */
142
+ healthySources: string[];
143
+ /** Sources that failed, with why. */
144
+ failedSources: Array<{
145
+ sourceId: string;
146
+ problem: string;
147
+ }>;
148
+ /**
149
+ * False when any source failed. ๐Ÿ”ด An empty inbox and an inbox we could not
150
+ * read are the same zero items and opposite meanings โ€” the first says there is
151
+ * no work, the second says we do not know.
152
+ */
153
+ complete: boolean;
154
+ }
155
+ export declare function buildIntakeInbox(results: IntakeSourceResult[], claims: IntakeClaims): IntakeInbox;
156
+ //# sourceMappingURL=intakeClaim.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intakeClaim.d.ts","sourceRoot":"","sources":["../src/intakeClaim.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH;+DAC+D;AAC/D,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAA;IAChB,2EAA2E;IAC3E,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,UAAU;IACzB;wEACoE;IACpE,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,EAAE,eAAe,CAAA;IACvB,KAAK,EAAE,MAAM,CAAA;IACb,2EAA2E;IAC3E,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,+DAA+D;IAC/D,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,GAAG,CAAC,EAAE,MAAM,CAAA;CAC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AMG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,iBAAiB;IAmC5E;sCACkC;IAClC,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO;IAOlD,qEAAqE;IACrE,OAAO,IAAI,KAAK,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,gBAAgB,CAAA;KAAE,CAAC;CAK9D;AAID,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,UAAU,EAAE,CAAA;IACnB,iDAAiD;IACjD,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,KAAK,CAAC,UAAU,GAAG;QAAE,KAAK,EAAE,gBAAgB,CAAA;KAAE,CAAC,CAAA;IACtD,6BAA6B;IAC7B,cAAc,EAAE,MAAM,EAAE,CAAA;IACxB,qCAAqC;IACrC,aAAa,EAAE,KAAK,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IAC3D;;;;OAIG;IACH,QAAQ,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,kBAAkB,EAAE,EAC7B,MAAM,EAAE,YAAY,GACnB,WAAW,CAgCb"}
@@ -0,0 +1,190 @@
1
+ /**
2
+ * Intake โ€” ADE ยง5.1, the first pillar of the developer's loop.
3
+ *
4
+ * Work arrives from everywhere: a typed instruction, a plan document, a TODO in
5
+ * the repository, an issue tracker, a scheduled trigger, another agent. This is
6
+ * the part that decides who gets to act on an item, and it is pure so that the
7
+ * one rule worth trusting can be tested without a tracker.
8
+ *
9
+ * ## ๐Ÿ”ด Claimed exactly once, under concurrent clients
10
+ *
11
+ * ยง5.1's gate. Two surfaces can be looking at the same queue, and two agents can
12
+ * be idle and eager. If both claim the same item, the same work is done twice โ€”
13
+ * and worse, both runs write to the same files, which is the merge-debt failure
14
+ * ยง5.7 exists to catch, arriving from the other end.
15
+ *
16
+ * A second claim is therefore REFUSED and told who holds it. Not queued, not
17
+ * silently re-granted: the caller needs to know it lost, because its next action
18
+ * (pick a different item) differs from the winner's.
19
+ *
20
+ * ## A source that FAILED is not a source with no work
21
+ *
22
+ * The same false-clean rule this codebase keeps re-learning. An unreachable
23
+ * tracker returning zero items looks exactly like a tracker with nothing to do,
24
+ * and an empty inbox reads as "nothing to pick up". So a failed source is
25
+ * reported as failed, and the aggregate says it is incomplete.
26
+ */
27
+ export function intakeItemId(source) {
28
+ return `${source.sourceId}:${source.externalId}`;
29
+ }
30
+ /**
31
+ * The claim registry.
32
+ *
33
+ * In-memory and single-process on purpose: the host IS the single authority for
34
+ * a user (ยง7), so this is where "exactly once" is decidable without a lock
35
+ * service. A detached host keeps that property โ€” it is one process by
36
+ * construction, which is the same reason the write lease lives there.
37
+ */
38
+ export class IntakeClaims {
39
+ #claims = new Map();
40
+ #now;
41
+ constructor(options = {}) {
42
+ this.#now = options.now ?? (() => Date.now());
43
+ }
44
+ state(itemId) {
45
+ return this.#claims.get(itemId) ?? { state: 'unclaimed' };
46
+ }
47
+ /**
48
+ * Takes an item for a client.
49
+ *
50
+ * ๐Ÿ”ด The second caller is REFUSED and told who won. Re-granting silently would
51
+ * put two runs on one item; queueing would leave a caller waiting for work it
52
+ * will never get. Losing is a fact it can act on.
53
+ */
54
+ claim(itemId, clientId) {
55
+ const current = this.state(itemId);
56
+ if (current.state === 'dispatched') {
57
+ return {
58
+ ok: false,
59
+ code: 'already-dispatched',
60
+ heldBy: current.byClientId,
61
+ runId: current.runId,
62
+ reason: `This item is already being worked on by run ${current.runId}.`,
63
+ };
64
+ }
65
+ if (current.state === 'claimed') {
66
+ // Idempotent for the HOLDER: a client that claims twice โ€” a retry, a
67
+ // reconnect โ€” has not lost anything and must not be told it did.
68
+ if (current.byClientId === clientId)
69
+ return { ok: true, claim: current };
70
+ return {
71
+ ok: false,
72
+ code: 'already-claimed',
73
+ heldBy: current.byClientId,
74
+ reason: `${current.byClientId} claimed this item first.`,
75
+ };
76
+ }
77
+ const claim = { state: 'claimed', byClientId: clientId, at: this.#now() };
78
+ this.#claims.set(itemId, claim);
79
+ return { ok: true, claim };
80
+ }
81
+ /**
82
+ * Which item was dispatched to this run โ€” ยง5.1's provenance, asked the way a
83
+ * reviewer asks it.
84
+ *
85
+ * ๐Ÿ”ด The claim map answers "who is working on this ITEM". A person looking at
86
+ * a RUN asks the opposite question: "where did this work come from?" โ€” and a
87
+ * run whose origin cannot be recovered is one nobody can audit, which is what
88
+ * the gate's "dispatches to a run whose provenance records the source item"
89
+ * requires.
90
+ *
91
+ * Returns the FIRST match, because dispatch binds an item to a run once and
92
+ * refuses a second dispatch; returning a list would promise a fan-out the
93
+ * claim rules cannot produce.
94
+ */
95
+ dispatchedTo(runId) {
96
+ for (const entry of this.entries()) {
97
+ if (entry.state.state === 'dispatched' && entry.state.runId === runId)
98
+ return entry.itemId;
99
+ }
100
+ return undefined;
101
+ }
102
+ /**
103
+ * Binds a claimed item to the run that will do it.
104
+ *
105
+ * Refuses unless the SAME client holds the claim โ€” dispatching someone else's
106
+ * item is how an item ends up worked twice with the registry showing one
107
+ * holder.
108
+ */
109
+ dispatch(itemId, clientId, runId) {
110
+ const current = this.state(itemId);
111
+ if (current.state === 'unclaimed') {
112
+ return {
113
+ ok: false,
114
+ code: 'already-claimed',
115
+ heldBy: '(nobody)',
116
+ reason: 'Claim this item before dispatching it.',
117
+ };
118
+ }
119
+ if (current.byClientId !== clientId) {
120
+ return current.state === 'dispatched'
121
+ ? {
122
+ ok: false,
123
+ code: 'already-dispatched',
124
+ heldBy: current.byClientId,
125
+ runId: current.runId,
126
+ reason: `This item is already being worked on by run ${current.runId}.`,
127
+ }
128
+ : {
129
+ ok: false,
130
+ code: 'already-claimed',
131
+ heldBy: current.byClientId,
132
+ reason: `${current.byClientId} holds this item.`,
133
+ };
134
+ }
135
+ this.#claims.set(itemId, {
136
+ state: 'dispatched',
137
+ byClientId: clientId,
138
+ at: this.#now(),
139
+ runId,
140
+ });
141
+ return { ok: true, claim: { state: 'claimed', byClientId: clientId, at: this.#now() } };
142
+ }
143
+ /** Gives an item back. Only the holder may โ€” otherwise any client could free
144
+ * another's work and take it. */
145
+ release(itemId, clientId) {
146
+ const current = this.state(itemId);
147
+ if (current.state === 'unclaimed' || current.byClientId !== clientId)
148
+ return false;
149
+ this.#claims.delete(itemId);
150
+ return true;
151
+ }
152
+ /** Every item this registry knows about, for a surface to render. */
153
+ entries() {
154
+ return [...this.#claims.entries()]
155
+ .map(([itemId, state]) => ({ itemId, state }))
156
+ .sort((left, right) => left.itemId.localeCompare(right.itemId));
157
+ }
158
+ }
159
+ export function buildIntakeInbox(results, claims) {
160
+ const healthySources = [];
161
+ const failedSources = [];
162
+ const items = [];
163
+ for (const result of results) {
164
+ if (result.problem) {
165
+ failedSources.push({ sourceId: result.sourceId, problem: result.problem });
166
+ // Its items are still included when it returned any: a partially readable
167
+ // source is more useful than none, and `complete: false` carries the doubt.
168
+ }
169
+ else {
170
+ healthySources.push(result.sourceId);
171
+ }
172
+ for (const item of result.items) {
173
+ items.push({ ...item, claim: claims.state(item.id) });
174
+ }
175
+ }
176
+ // Oldest first: intake is a queue, and the item that has waited longest is the
177
+ // one most likely to be forgotten. Ties break on id so the order is stable.
178
+ items.sort((left, right) => {
179
+ const leftAt = left.createdAt ?? 0;
180
+ const rightAt = right.createdAt ?? 0;
181
+ return leftAt === rightAt ? left.id.localeCompare(right.id) : leftAt - rightAt;
182
+ });
183
+ return {
184
+ items,
185
+ healthySources,
186
+ failedSources,
187
+ complete: failedSources.length === 0,
188
+ };
189
+ }
190
+ //# sourceMappingURL=intakeClaim.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intakeClaim.js","sourceRoot":"","sources":["../src/intakeClaim.ts"],"names":[],"mapp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C,MAAM,KAAK,CAAC;KACrC,CAAA;AACH,CAAC"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * What a knowledge surface may SHOW โ€” ADE ยง5.8, the presentation half.
3
+ *
4
+ * `knowledge.list` returns every fact ever recorded, including ones a later fact
5
+ * replaced. This decides which are CURRENT, which are history, and what must be
6
+ * said about the store keeping them.
7
+ *
8
+ * ## ๐Ÿ”ด Superseded facts are history, never deleted and never mixed in
9
+ *
10
+ * The store keeps "we use npm" after "we moved to pnpm" on purpose โ€” *"when did
11
+ * this change, and who decided?"* is a question people ask. But a list that
12
+ * showed both as current would be worse than one that dropped the old fact: a
13
+ * reader scanning it comes away believing the workspace holds two contradictory
14
+ * beliefs, which is exactly what supersession exists to prevent.
15
+ *
16
+ * ## The durability warning is not a footnote
17
+ *
18
+ * A surface that renders facts identically whether or not they survive a restart
19
+ * invites someone to teach the workspace something important and lose it. When
20
+ * the store is not durable, that is the first thing on screen.
21
+ */
22
+ export interface KnowledgeBoardEntryInput {
23
+ id: string;
24
+ subject: string;
25
+ fact: string;
26
+ pinned?: boolean;
27
+ runId: string;
28
+ providerId?: string;
29
+ at: number;
30
+ }
31
+ export interface KnowledgeBoardInput {
32
+ available: boolean;
33
+ entries: KnowledgeBoardEntryInput[];
34
+ durable: boolean;
35
+ reason?: string;
36
+ }
37
+ export interface KnowledgeBoardRow {
38
+ id: string;
39
+ subject: string;
40
+ fact: string;
41
+ pinned: boolean;
42
+ /** "learned by claude in run r7" โ€” provenance a person can read. */
43
+ provenance: string;
44
+ at: number;
45
+ }
46
+ export interface KnowledgeBoard {
47
+ /** What the workspace currently believes, pinned first then newest. */
48
+ current: KnowledgeBoardRow[];
49
+ /** Replaced by a later fact about the same subject. Kept, shown apart. */
50
+ history: KnowledgeBoardRow[];
51
+ /** Present when the store does not survive a restart, or cannot be read. */
52
+ notice?: string;
53
+ /** True only when these facts will still be here tomorrow. */
54
+ durable: boolean;
55
+ }
56
+ export declare function projectKnowledgeBoard(input: KnowledgeBoardInput): KnowledgeBoard;
57
+ //# sourceMappingURL=knowledgeBoardProjection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"knowledgeBoardProjection.d.ts","sourceRoot":"","sources":["../src/knowledgeBoardProjection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,MAAM,WAAW,wBAAwB;IACvC,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,EAAE,EAAE,MAAM,CAAA;CACX;AAED,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,OAAO,CAAA;IAClB,OAAO,EAAE,wBAAwB,EAAE,CAAA;IACnC,OAAO,EAAE,OAAO,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,OAAO,CAAA;IACf,oEAAoE;IACpE,UAAU,EAAE,MAAM,CAAA;IAClB,EAAE,EAAE,MAAM,CAAA;CACX;AAED,MAAM,WAAW,cAAc;IAC7B,uEAAuE;IACvE,OAAO,EAAE,iBAAiB,EAAE,CAAA;IAC5B,0EAA0E;IAC1E,OAAO,EAAE,iBAAiB,EAAE,CAAA;IAC5B,4EAA4E;IAC5E,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,8DAA8D;IAC9D,OAAO,EAAE,OAAO,CAAA;CACjB;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,mBAAmB,GAAG,cAAc,CAyChF"}