@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.
- package/LICENSE +67 -0
- package/dist/agentDiscovery.d.ts +97 -0
- package/dist/agentDiscovery.d.ts.map +1 -0
- package/dist/agentDiscovery.js +93 -0
- package/dist/agentDiscovery.js.map +1 -0
- package/dist/capabilityRouting.d.ts +72 -0
- package/dist/capabilityRouting.d.ts.map +1 -0
- package/dist/capabilityRouting.js +124 -0
- package/dist/capabilityRouting.js.map +1 -0
- package/dist/capabilityTier.d.ts +105 -0
- package/dist/capabilityTier.d.ts.map +1 -0
- package/dist/capabilityTier.js +120 -0
- package/dist/capabilityTier.js.map +1 -0
- package/dist/combinationVerification.d.ts +101 -0
- package/dist/combinationVerification.d.ts.map +1 -0
- package/dist/combinationVerification.js +115 -0
- package/dist/combinationVerification.js.map +1 -0
- package/dist/context/agentAttachedContextPrompt.d.ts +13 -0
- package/dist/context/agentAttachedContextPrompt.d.ts.map +1 -0
- package/dist/context/agentAttachedContextPrompt.js +50 -0
- package/dist/context/agentAttachedContextPrompt.js.map +1 -0
- package/dist/context/agentModelContext.d.ts +77 -0
- package/dist/context/agentModelContext.d.ts.map +1 -0
- package/dist/context/agentModelContext.js +297 -0
- package/dist/context/agentModelContext.js.map +1 -0
- package/dist/fanOutPlanner.d.ts +65 -0
- package/dist/fanOutPlanner.d.ts.map +1 -0
- package/dist/fanOutPlanner.js +78 -0
- package/dist/fanOutPlanner.js.map +1 -0
- package/dist/fleetBoardProjection.d.ts +143 -0
- package/dist/fleetBoardProjection.d.ts.map +1 -0
- package/dist/fleetBoardProjection.js +156 -0
- package/dist/fleetBoardProjection.js.map +1 -0
- package/dist/fleetProjection.d.ts +63 -0
- package/dist/fleetProjection.d.ts.map +1 -0
- package/dist/fleetProjection.js +86 -0
- package/dist/fleetProjection.js.map +1 -0
- package/dist/hostBackedCapabilities.d.ts +50 -0
- package/dist/hostBackedCapabilities.d.ts.map +1 -0
- package/dist/hostBackedCapabilities.js +66 -0
- package/dist/hostBackedCapabilities.js.map +1 -0
- package/dist/index.d.ts +54 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +134 -0
- package/dist/index.js.map +1 -0
- package/dist/intakeBoardProjection.d.ts +75 -0
- package/dist/intakeBoardProjection.d.ts.map +1 -0
- package/dist/intakeBoardProjection.js +90 -0
- package/dist/intakeBoardProjection.js.map +1 -0
- package/dist/intakeClaim.d.ts +156 -0
- package/dist/intakeClaim.d.ts.map +1 -0
- package/dist/intakeClaim.js +190 -0
- package/dist/intakeClaim.js.map +1 -0
- package/dist/knowledgeBoardProjection.d.ts +57 -0
- package/dist/knowledgeBoardProjection.d.ts.map +1 -0
- package/dist/knowledgeBoardProjection.js +74 -0
- package/dist/knowledgeBoardProjection.js.map +1 -0
- package/dist/landingOverlap.d.ts +127 -0
- package/dist/landingOverlap.d.ts.map +1 -0
- package/dist/landingOverlap.js +107 -0
- package/dist/landingOverlap.js.map +1 -0
- package/dist/landingQueue.d.ts +152 -0
- package/dist/landingQueue.d.ts.map +1 -0
- package/dist/landingQueue.js +258 -0
- package/dist/landingQueue.js.map +1 -0
- package/dist/markdown/markdownWindowsPaths.d.ts +20 -0
- package/dist/markdown/markdownWindowsPaths.d.ts.map +1 -0
- package/dist/markdown/markdownWindowsPaths.js +208 -0
- package/dist/markdown/markdownWindowsPaths.js.map +1 -0
- package/dist/reviewProjection.d.ts +118 -0
- package/dist/reviewProjection.d.ts.map +1 -0
- package/dist/reviewProjection.js +133 -0
- package/dist/reviewProjection.js.map +1 -0
- package/dist/runDiff.d.ts +86 -0
- package/dist/runDiff.d.ts.map +1 -0
- package/dist/runDiff.js +103 -0
- package/dist/runDiff.js.map +1 -0
- package/dist/runtime/agentReasoningEffort.d.ts +22 -0
- package/dist/runtime/agentReasoningEffort.d.ts.map +1 -0
- package/dist/runtime/agentReasoningEffort.js +76 -0
- package/dist/runtime/agentReasoningEffort.js.map +1 -0
- package/dist/runtime/agentRuntimeProvider.d.ts +12 -0
- package/dist/runtime/agentRuntimeProvider.d.ts.map +1 -0
- package/dist/runtime/agentRuntimeProvider.js +294 -0
- package/dist/runtime/agentRuntimeProvider.js.map +1 -0
- package/dist/runtime/agentRuntimeProviderTypes.d.ts +100 -0
- package/dist/runtime/agentRuntimeProviderTypes.d.ts.map +1 -0
- package/dist/runtime/agentRuntimeProviderTypes.js +2 -0
- package/dist/runtime/agentRuntimeProviderTypes.js.map +1 -0
- package/dist/runtime/conversationRuntime.d.ts +53 -0
- package/dist/runtime/conversationRuntime.d.ts.map +1 -0
- package/dist/runtime/conversationRuntime.js +207 -0
- package/dist/runtime/conversationRuntime.js.map +1 -0
- package/dist/runtime/legacyAgentRuntimeEvents.d.ts +65 -0
- package/dist/runtime/legacyAgentRuntimeEvents.d.ts.map +1 -0
- package/dist/runtime/legacyAgentRuntimeEvents.js +104 -0
- package/dist/runtime/legacyAgentRuntimeEvents.js.map +1 -0
- package/dist/runtimeProjection.d.ts +19 -0
- package/dist/runtimeProjection.d.ts.map +1 -0
- package/dist/runtimeProjection.js +133 -0
- package/dist/runtimeProjection.js.map +1 -0
- package/dist/sessionBoardProjection.d.ts +84 -0
- package/dist/sessionBoardProjection.d.ts.map +1 -0
- package/dist/sessionBoardProjection.js +103 -0
- package/dist/sessionBoardProjection.js.map +1 -0
- package/dist/sessionMode.d.ts +115 -0
- package/dist/sessionMode.d.ts.map +1 -0
- package/dist/sessionMode.js +98 -0
- package/dist/sessionMode.js.map +1 -0
- package/dist/workspace/workspaceSelectionContinuation.d.ts +8 -0
- package/dist/workspace/workspaceSelectionContinuation.d.ts.map +1 -0
- package/dist/workspace/workspaceSelectionContinuation.js +18 -0
- package/dist/workspace/workspaceSelectionContinuation.js.map +1 -0
- package/dist/workspaceKnowledge.d.ts +90 -0
- package/dist/workspaceKnowledge.d.ts.map +1 -0
- package/dist/workspaceKnowledge.js +103 -0
- package/dist/workspaceKnowledge.js.map +1 -0
- package/dist/writeLease.d.ts +92 -0
- package/dist/writeLease.d.ts.map +1 -0
- package/dist/writeLease.js +108 -0
- package/dist/writeLease.js.map +1 -0
- package/package.json +29 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspaceKnowledge.js","sourceRoot":"","sources":["../src/workspaceKnowledge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAmDH,MAAM,iBAAiB,GAAG,KAAK,CAAA;AAE/B;;;;;;GAMG;AACH,MAAM,UAAU,wBAAwB,CACtC,OAA2C,EAC3C,UAAqC,EAAE;IAEvC,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,iBAAiB,CAAA;IAEtD,2EAA2E;IAC3E,wCAAwC;IACxC,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAAmC,CAAA;IACnE,MAAM,UAAU,GAA8B,EAAE,CAAA;IAChD,KAAK,MAAM,KAAK,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CACpD,IAAI,CAAC,UAAU,CAAC,EAAE,KAAK,KAAK,CAAC,UAAU,CAAC,EAAE;QACxC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;QACjC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,GAAG,KAAK,CAAC,UAAU,CAAC,EAAE,CAC7C,EAAE,CAAC;QACF,MAAM,QAAQ,GAAG,gBAAgB,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QACpD,IAAI,QAAQ;YAAE,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QACvC,gBAAgB,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IAC5C,CAAC;IAED,MAAM,OAAO,GAAG,CAAC,GAAG,gBAAgB,CAAC,MAAM,EAAE,CAA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kEAAkE;AAClE,MAAM,UAAU,wBAAwB,CAAC,SAA6B;IACpE,IAAI,SAAS,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAA;IAC7C,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,CAAC,OAAO,KAAK,KAAK,CAAC,IAAI,EAAE,CAAC,CAAA;IACnF,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;QACxB,2EAA2E;QAC3E,yDAAyD;QACzD,KAAK,CAAC,IAAI,CAAC,MAAM,SAAS,CAAC,OAAO,CAAC,MAAM,qCAAqC,CAAC,CAAA;IACjF,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACzB,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The session write lease — ADE spec §5.5, takeover with explicit semantics.
|
|
3
|
+
*
|
|
4
|
+
* > "When a human types into the agent's terminal, the agent yields, and the
|
|
5
|
+
* > transcript records that a human intervened. **Two writers into one session
|
|
6
|
+
* > with no arbitration corrupts the run.** Most of the terminal tier is sloppy
|
|
7
|
+
* > here precisely because tmux gives them attach for free and they never
|
|
8
|
+
* > modelled the handoff. This is the hard part and the part worth owning."
|
|
9
|
+
*
|
|
10
|
+
* ## What "the agent yields" can and cannot mean
|
|
11
|
+
*
|
|
12
|
+
* 🔴 The agent is a **running process**. We cannot stop it writing to its own
|
|
13
|
+
* stdout, and we should not want to: its output during a takeover is exactly
|
|
14
|
+
* the evidence a reviewer needs to see what the human interrupted. So a lease
|
|
15
|
+
* over *output* would be both unenforceable and wrong.
|
|
16
|
+
*
|
|
17
|
+
* **The lease governs INPUT — who may write INTO the session.** That is the
|
|
18
|
+
* thing we genuinely own (§2.8: we give every session a terminal and own both
|
|
19
|
+
* ends of it), and it is where the corruption actually happens: two writers
|
|
20
|
+
* interleaving keystrokes into one PTY produces a command neither of them
|
|
21
|
+
* typed. Agent output continues throughout and stays on the transcript.
|
|
22
|
+
*
|
|
23
|
+
* ## Three rules, each of which is a way to get this wrong
|
|
24
|
+
*
|
|
25
|
+
* 1. **A human PREEMPTS the agent; a human never queues behind it.** Typing is
|
|
26
|
+
* the takeover — there is no request-and-wait, because the case this exists
|
|
27
|
+
* for is an agent going wrong *now*.
|
|
28
|
+
* 2. **A human does NOT preempt another human.** Two humans interleaving is the
|
|
29
|
+
* same corrupted command as a human and an agent, and "most recent typist
|
|
30
|
+
* wins" would make it silent. The second is refused and told who holds it.
|
|
31
|
+
* 3. **The agent never takes the lease back on its own.** Return is an explicit
|
|
32
|
+
* human act. An idle timer that silently hands control back mid-thought
|
|
33
|
+
* would resume the agent while a human is composing — reintroducing exactly
|
|
34
|
+
* the interleaving the lease prevents, at the least observable moment.
|
|
35
|
+
*/
|
|
36
|
+
/** Who may write into the session right now. */
|
|
37
|
+
export type WriteLeaseHolder = {
|
|
38
|
+
kind: 'agent';
|
|
39
|
+
} | {
|
|
40
|
+
kind: 'human';
|
|
41
|
+
viewerId: string;
|
|
42
|
+
};
|
|
43
|
+
export interface WriteLeaseState {
|
|
44
|
+
holder: WriteLeaseHolder;
|
|
45
|
+
/** When the current holder took it. */
|
|
46
|
+
since: number;
|
|
47
|
+
/** How many times a human has taken over this session, ever. */
|
|
48
|
+
interventions: number;
|
|
49
|
+
}
|
|
50
|
+
export type WriteLeaseTransition = {
|
|
51
|
+
ok: true;
|
|
52
|
+
state: WriteLeaseState;
|
|
53
|
+
/** True when this transition took the lease FROM the agent. */
|
|
54
|
+
agentYielded: boolean;
|
|
55
|
+
} | {
|
|
56
|
+
ok: false;
|
|
57
|
+
code: 'held_by_another_human';
|
|
58
|
+
heldBy: string;
|
|
59
|
+
reason: string;
|
|
60
|
+
} | {
|
|
61
|
+
ok: false;
|
|
62
|
+
code: 'not_holder';
|
|
63
|
+
reason: string;
|
|
64
|
+
};
|
|
65
|
+
/** A fresh session: the agent writes, nobody has intervened. */
|
|
66
|
+
export declare function openWriteLease(now: number): WriteLeaseState;
|
|
67
|
+
/**
|
|
68
|
+
* A human types. This IS the takeover — §5.5 has no separate request step.
|
|
69
|
+
*
|
|
70
|
+
* Re-taking a lease you already hold is a no-op rather than an error: a human
|
|
71
|
+
* types many keystrokes, and every one of them after the first must not count
|
|
72
|
+
* as a new intervention or the transcript would report a hundred takeovers.
|
|
73
|
+
*/
|
|
74
|
+
export declare function humanTakesWriteLease(state: WriteLeaseState, viewerId: string, now: number): WriteLeaseTransition;
|
|
75
|
+
/**
|
|
76
|
+
* The human hands the session back. Rule 3: only this returns the lease.
|
|
77
|
+
*
|
|
78
|
+
* Someone who does not hold it cannot release it — otherwise one surface could
|
|
79
|
+
* hand the agent control while another human was mid-command.
|
|
80
|
+
*/
|
|
81
|
+
export declare function humanReleasesWriteLease(state: WriteLeaseState, viewerId: string, now: number): WriteLeaseTransition;
|
|
82
|
+
/**
|
|
83
|
+
* Whether the host may inject agent-side input right now.
|
|
84
|
+
*
|
|
85
|
+
* ⚠️ INPUT only. Agent OUTPUT is never gated — see the header. A caller that
|
|
86
|
+
* used this to suppress output would hide the very thing a reviewer needs to
|
|
87
|
+
* understand what the human interrupted.
|
|
88
|
+
*/
|
|
89
|
+
export declare function agentMayWrite(state: WriteLeaseState): boolean;
|
|
90
|
+
/** Who holds it, for a surface to show without inspecting the union. */
|
|
91
|
+
export declare function describeWriteLease(state: WriteLeaseState): string;
|
|
92
|
+
//# sourceMappingURL=writeLease.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writeLease.d.ts","sourceRoot":"","sources":["../src/writeLease.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,gDAAgD;AAChD,MAAM,MAAM,gBAAgB,GACxB;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GACjB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAA;AAEvC,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,gBAAgB,CAAA;IACxB,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAA;IACb,gEAAgE;IAChE,aAAa,EAAE,MAAM,CAAA;CACtB;AAED,MAAM,MAAM,oBAAoB,GAC5B;IACE,EAAE,EAAE,IAAI,CAAA;IACR,KAAK,EAAE,eAAe,CAAA;IACtB,+DAA+D;IAC/D,YAAY,EAAE,OAAO,CAAA;CACtB,GACD;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,uBAAuB,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC5E;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,YAAY,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAA;AAErD,gEAAgE;AAChE,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,CAE3D;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,eAAe,EACtB,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,GACV,oBAAoB,CAyBtB;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,eAAe,EACtB,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,GACV,oBAAoB,CAatB;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAE7D;AAED,wEAAwE;AACxE,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CAIjE"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The session write lease — ADE spec §5.5, takeover with explicit semantics.
|
|
3
|
+
*
|
|
4
|
+
* > "When a human types into the agent's terminal, the agent yields, and the
|
|
5
|
+
* > transcript records that a human intervened. **Two writers into one session
|
|
6
|
+
* > with no arbitration corrupts the run.** Most of the terminal tier is sloppy
|
|
7
|
+
* > here precisely because tmux gives them attach for free and they never
|
|
8
|
+
* > modelled the handoff. This is the hard part and the part worth owning."
|
|
9
|
+
*
|
|
10
|
+
* ## What "the agent yields" can and cannot mean
|
|
11
|
+
*
|
|
12
|
+
* 🔴 The agent is a **running process**. We cannot stop it writing to its own
|
|
13
|
+
* stdout, and we should not want to: its output during a takeover is exactly
|
|
14
|
+
* the evidence a reviewer needs to see what the human interrupted. So a lease
|
|
15
|
+
* over *output* would be both unenforceable and wrong.
|
|
16
|
+
*
|
|
17
|
+
* **The lease governs INPUT — who may write INTO the session.** That is the
|
|
18
|
+
* thing we genuinely own (§2.8: we give every session a terminal and own both
|
|
19
|
+
* ends of it), and it is where the corruption actually happens: two writers
|
|
20
|
+
* interleaving keystrokes into one PTY produces a command neither of them
|
|
21
|
+
* typed. Agent output continues throughout and stays on the transcript.
|
|
22
|
+
*
|
|
23
|
+
* ## Three rules, each of which is a way to get this wrong
|
|
24
|
+
*
|
|
25
|
+
* 1. **A human PREEMPTS the agent; a human never queues behind it.** Typing is
|
|
26
|
+
* the takeover — there is no request-and-wait, because the case this exists
|
|
27
|
+
* for is an agent going wrong *now*.
|
|
28
|
+
* 2. **A human does NOT preempt another human.** Two humans interleaving is the
|
|
29
|
+
* same corrupted command as a human and an agent, and "most recent typist
|
|
30
|
+
* wins" would make it silent. The second is refused and told who holds it.
|
|
31
|
+
* 3. **The agent never takes the lease back on its own.** Return is an explicit
|
|
32
|
+
* human act. An idle timer that silently hands control back mid-thought
|
|
33
|
+
* would resume the agent while a human is composing — reintroducing exactly
|
|
34
|
+
* the interleaving the lease prevents, at the least observable moment.
|
|
35
|
+
*/
|
|
36
|
+
/** A fresh session: the agent writes, nobody has intervened. */
|
|
37
|
+
export function openWriteLease(now) {
|
|
38
|
+
return { holder: { kind: 'agent' }, since: now, interventions: 0 };
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A human types. This IS the takeover — §5.5 has no separate request step.
|
|
42
|
+
*
|
|
43
|
+
* Re-taking a lease you already hold is a no-op rather than an error: a human
|
|
44
|
+
* types many keystrokes, and every one of them after the first must not count
|
|
45
|
+
* as a new intervention or the transcript would report a hundred takeovers.
|
|
46
|
+
*/
|
|
47
|
+
export function humanTakesWriteLease(state, viewerId, now) {
|
|
48
|
+
if (state.holder.kind === 'human') {
|
|
49
|
+
if (state.holder.viewerId === viewerId) {
|
|
50
|
+
return { ok: true, state, agentYielded: false };
|
|
51
|
+
}
|
|
52
|
+
// Rule 2. Refusing NAMES the holder, so the second human can talk to them —
|
|
53
|
+
// the same shape as a refused claim in the coordination spec, and for the
|
|
54
|
+
// same reason: a bare failure leaves the caller to spin or guess.
|
|
55
|
+
return {
|
|
56
|
+
ok: false,
|
|
57
|
+
code: 'held_by_another_human',
|
|
58
|
+
heldBy: state.holder.viewerId,
|
|
59
|
+
reason: `${state.holder.viewerId} is typing into this session; two writers interleave into one command`,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
ok: true,
|
|
64
|
+
state: {
|
|
65
|
+
holder: { kind: 'human', viewerId },
|
|
66
|
+
since: now,
|
|
67
|
+
interventions: state.interventions + 1,
|
|
68
|
+
},
|
|
69
|
+
agentYielded: true,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The human hands the session back. Rule 3: only this returns the lease.
|
|
74
|
+
*
|
|
75
|
+
* Someone who does not hold it cannot release it — otherwise one surface could
|
|
76
|
+
* hand the agent control while another human was mid-command.
|
|
77
|
+
*/
|
|
78
|
+
export function humanReleasesWriteLease(state, viewerId, now) {
|
|
79
|
+
if (state.holder.kind !== 'human' || state.holder.viewerId !== viewerId) {
|
|
80
|
+
return {
|
|
81
|
+
ok: false,
|
|
82
|
+
code: 'not_holder',
|
|
83
|
+
reason: 'only the holder can return the session to the agent',
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
ok: true,
|
|
88
|
+
state: { holder: { kind: 'agent' }, since: now, interventions: state.interventions },
|
|
89
|
+
agentYielded: false,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Whether the host may inject agent-side input right now.
|
|
94
|
+
*
|
|
95
|
+
* ⚠️ INPUT only. Agent OUTPUT is never gated — see the header. A caller that
|
|
96
|
+
* used this to suppress output would hide the very thing a reviewer needs to
|
|
97
|
+
* understand what the human interrupted.
|
|
98
|
+
*/
|
|
99
|
+
export function agentMayWrite(state) {
|
|
100
|
+
return state.holder.kind === 'agent';
|
|
101
|
+
}
|
|
102
|
+
/** Who holds it, for a surface to show without inspecting the union. */
|
|
103
|
+
export function describeWriteLease(state) {
|
|
104
|
+
return state.holder.kind === 'agent'
|
|
105
|
+
? 'the agent is driving'
|
|
106
|
+
: `${state.holder.viewerId} has taken over`;
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=writeLease.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writeLease.js","sourceRoot":"","sources":["../src/writeLease.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAyBH,gEAAgE;AAChE,MAAM,UAAU,cAAc,CAAC,GAAW;IACxC,OAAO,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,EAAE,CAAC,EAAE,CAAA;AACpE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAClC,KAAsB,EACtB,QAAgB,EAChB,GAAW;IAEX,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAClC,IAAI,KAAK,CAAC,MAAM,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;YACvC,OAAO,EAAE,EAAE,EAAE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AAsB;IACvD,OAAO,KAAK,CAAC,MAAM,CAAC,IAAI,KAAK,OAAO;QAClC,CAAC,CAAC,sBAAsB;QACxB,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,QAAQ,iBAAiB,CAAA;AAC/C,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xenosystem/agent-interface-core",
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"license": "UNLICENSED",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public"
|
|
19
|
+
},
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/XENO-CORPORATION/xeno-agent-interface.git",
|
|
23
|
+
"directory": "packages/core"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@xenosystem/agent-interface-contract": "0.1.3"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {}
|
|
29
|
+
}
|