@ouispec/agent-core 0.2.2 → 0.7.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.
- package/dist/approvals/types.d.ts +77 -0
- package/dist/approvals/types.d.ts.map +1 -1
- package/dist/approvals/types.js +14 -0
- package/dist/approvals/types.js.map +1 -1
- package/dist/browser.d.ts +1 -0
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +1 -0
- package/dist/browser.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/protocol/index.d.ts +6 -0
- package/dist/protocol/index.d.ts.map +1 -1
- package/dist/protocol/index.js +2 -0
- package/dist/protocol/index.js.map +1 -1
- package/dist/turns/index.d.ts +2 -0
- package/dist/turns/index.d.ts.map +1 -0
- package/dist/turns/index.js +2 -0
- package/dist/turns/index.js.map +1 -0
- package/dist/turns/types.d.ts +71 -0
- package/dist/turns/types.d.ts.map +1 -0
- package/dist/turns/types.js +31 -0
- package/dist/turns/types.js.map +1 -0
- package/dist/types/client-config.d.ts +17 -0
- package/dist/types/client-config.d.ts.map +1 -1
- package/package.json +4 -4
|
@@ -12,5 +12,82 @@ export declare const DEFAULT_APPROVAL_TTL_MS: number;
|
|
|
12
12
|
/** The longest an action may declare an approval lasts. */
|
|
13
13
|
export declare const MAX_APPROVAL_TTL_MS: number;
|
|
14
14
|
export declare const APPROVAL_CHANNELS: readonly ApprovalChannel[];
|
|
15
|
+
/**
|
|
16
|
+
* How long the store remembers that an approval was asked for and never
|
|
17
|
+
* decided, after it has expired: long enough for a conversation picked up
|
|
18
|
+
* days later to be told its call expired, rather than that it still waits.
|
|
19
|
+
*/
|
|
20
|
+
export declare const EXPIRED_APPROVAL_MEMORY_MS: number;
|
|
21
|
+
/**
|
|
22
|
+
* How long a turn that claimed an expiry has to store it and confirm. A turn
|
|
23
|
+
* that dies in between confirms nothing, and cannot release anything either:
|
|
24
|
+
* its claim lapses on the store's clock and the next turn claims again, so the
|
|
25
|
+
* stored conversation does not say "waiting" for good.
|
|
26
|
+
*/
|
|
27
|
+
export declare const EXPIRY_CLAIM_LEASE_MS: number;
|
|
28
|
+
/**
|
|
29
|
+
* Where an approval stands when a later turn finds its call still stored as
|
|
30
|
+
* waiting, and asks to settle it (`POST /internal/approvals/:id/settle`):
|
|
31
|
+
*
|
|
32
|
+
* - `claimed`: it expired without having run — undecided, or approved and
|
|
33
|
+
* never used (`decided`) — and this caller holds the claim to store
|
|
34
|
+
* that, for `EXPIRY_CLAIM_LEASE_MS`. The caller stores the call's result as
|
|
35
|
+
* expired, then confirms; confirmed, the claim is permanent.
|
|
36
|
+
* - `already`: it expired without having run, and another turn holds the claim
|
|
37
|
+
* or has confirmed it. The caller tells the model so for its own turn, and stores
|
|
38
|
+
* nothing.
|
|
39
|
+
* - `open`: it is still pending, or approved and not yet used. The card is live.
|
|
40
|
+
* - `unknown`: the store cannot say it expired undecided — it was declined, or
|
|
41
|
+
* approved and used, it is another user's or another conversation's, it was
|
|
42
|
+
* asked for before the store kept this memory, or the memory has lapsed.
|
|
43
|
+
* Nothing is changed.
|
|
44
|
+
* - `confirmed`: the answer to a confirmation.
|
|
45
|
+
*
|
|
46
|
+
* Only the store's own clock decides that an approval has expired.
|
|
47
|
+
*/
|
|
48
|
+
export type ApprovalSettleOutcome = 'claimed' | 'already' | 'open' | 'unknown' | 'confirmed';
|
|
49
|
+
export interface ApprovalSettlement {
|
|
50
|
+
approvalId: string;
|
|
51
|
+
outcome: ApprovalSettleOutcome;
|
|
52
|
+
/** When it expired (epoch ms), for `claimed` and `already`. */
|
|
53
|
+
expiresAt?: number;
|
|
54
|
+
/**
|
|
55
|
+
* For `claimed` and `already`: the user had approved it, and it expired
|
|
56
|
+
* before it was used (the turn that would have run it never did). Absent
|
|
57
|
+
* when nobody decided it.
|
|
58
|
+
*/
|
|
59
|
+
decided?: 'approved';
|
|
60
|
+
/**
|
|
61
|
+
* For `claimed` and `already`: set when the approval did not run out of
|
|
62
|
+
* time but was withdrawn (ADR-0252 §2.6). Absent when its time ran out.
|
|
63
|
+
*/
|
|
64
|
+
withdrawn?: ApprovalWithdrawReason;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Why an approval was expired before its time (ADR-0252 §2.6):
|
|
68
|
+
* - `superseded`: the person sent a new message while the card waited.
|
|
69
|
+
* - `stopped`: the turn that asked for it was stopped as it asked.
|
|
70
|
+
*
|
|
71
|
+
* A withdrawn approval is expired from that moment: its card is dead and its
|
|
72
|
+
* token answers `used`. What is stored and told to the model says why, so it
|
|
73
|
+
* reads "withdrawn because you sent a new message", not "it timed out".
|
|
74
|
+
*/
|
|
75
|
+
export type ApprovalWithdrawReason = 'superseded' | 'stopped';
|
|
76
|
+
export declare const APPROVAL_WITHDRAW_REASONS: readonly ApprovalWithdrawReason[];
|
|
77
|
+
/** The answer to withdrawing an approval (`POST /internal/approvals/:id/settle` with `expire`). */
|
|
78
|
+
export interface ApprovalWithdrawal {
|
|
79
|
+
approvalId: string;
|
|
80
|
+
/**
|
|
81
|
+
* - `withdrawn`: it was pending, or approved and not yet used, and is now expired.
|
|
82
|
+
* - `settled`: it had already ended (declined, used, expired or withdrawn); nothing changed.
|
|
83
|
+
* - `unknown`: the store holds no such approval for this owner.
|
|
84
|
+
*/
|
|
85
|
+
outcome: 'withdrawn' | 'settled' | 'unknown';
|
|
86
|
+
}
|
|
87
|
+
/** Whose approval is asked about: the same ownership the other approval routes check. */
|
|
88
|
+
export interface ApprovalOwner {
|
|
89
|
+
userId: string;
|
|
90
|
+
conversationId: string;
|
|
91
|
+
}
|
|
15
92
|
export type { ActionRequestApproval, ApprovalChannel, ApprovalContinuation, ApprovalDecidePayload, ApprovalDecideResult, ApprovalDecision, ApprovalEffect, ApprovalGrant, ApprovalPreview, ApprovalPreviewArgument, ApprovalRedeemResult, ApprovalRefusal, ApprovalRefusalReason, ApprovalRequiredEvent, ApprovalStatus, ApprovalTokenClaims, ApprovedCall, PendingApprovalInput, } from '@ouispec/contract';
|
|
16
93
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/approvals/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAyB,eAAe,EAAiB,MAAM,mBAAmB,CAAC;AAE/F;;;;;GAKG;AAEH,gFAAgF;AAChF,eAAO,MAAM,qBAAqB,oBAAoB,CAAC;AAEvD,uFAAuF;AACvF,eAAO,MAAM,uBAAuB,QAAa,CAAC;AAClD,2DAA2D;AAC3D,eAAO,MAAM,mBAAmB,QAAc,CAAC;AAE/C,eAAO,MAAM,iBAAiB,EAAE,SAAS,eAAe,EAA4C,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/approvals/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAyB,eAAe,EAAiB,MAAM,mBAAmB,CAAC;AAE/F;;;;;GAKG;AAEH,gFAAgF;AAChF,eAAO,MAAM,qBAAqB,oBAAoB,CAAC;AAEvD,uFAAuF;AACvF,eAAO,MAAM,uBAAuB,QAAa,CAAC;AAClD,2DAA2D;AAC3D,eAAO,MAAM,mBAAmB,QAAc,CAAC;AAE/C,eAAO,MAAM,iBAAiB,EAAE,SAAS,eAAe,EAA4C,CAAC;AAErG;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,QAAwB,CAAC;AAEhE;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,QAAa,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,MAAM,qBAAqB,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,WAAW,CAAC;AAE7F,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,qBAAqB,CAAC;IAC/B,+DAA+D;IAC/D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,OAAO,CAAC,EAAE,UAAU,CAAC;IACrB;;;OAGG;IACH,SAAS,CAAC,EAAE,sBAAsB,CAAC;CACpC;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,sBAAsB,GAAG,YAAY,GAAG,SAAS,CAAC;AAE9D,eAAO,MAAM,yBAAyB,EAAE,SAAS,sBAAsB,EAA8B,CAAC;AAEtG,mGAAmG;AACnG,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,OAAO,EAAE,WAAW,GAAG,SAAS,GAAG,SAAS,CAAC;CAC9C;AAED,yFAAyF;AACzF,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;CACxB;AAKD,YAAY,EACV,qBAAqB,EACrB,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,eAAe,EACf,uBAAuB,EACvB,oBAAoB,EACpB,eAAe,EACf,qBAAqB,EACrB,qBAAqB,EACrB,cAAc,EACd,mBAAmB,EACnB,YAAY,EACZ,oBAAoB,GACrB,MAAM,mBAAmB,CAAC"}
|
package/dist/approvals/types.js
CHANGED
|
@@ -11,6 +11,20 @@ export const DEFAULT_APPROVAL_TTL_MS = 5 * 60_000;
|
|
|
11
11
|
/** The longest an action may declare an approval lasts. */
|
|
12
12
|
export const MAX_APPROVAL_TTL_MS = 30 * 60_000;
|
|
13
13
|
export const APPROVAL_CHANNELS = ['ui', 'voice', 'phone', 'sms', 'chat'];
|
|
14
|
+
/**
|
|
15
|
+
* How long the store remembers that an approval was asked for and never
|
|
16
|
+
* decided, after it has expired: long enough for a conversation picked up
|
|
17
|
+
* days later to be told its call expired, rather than that it still waits.
|
|
18
|
+
*/
|
|
19
|
+
export const EXPIRED_APPROVAL_MEMORY_MS = 30 * 24 * 60 * 60_000;
|
|
20
|
+
/**
|
|
21
|
+
* How long a turn that claimed an expiry has to store it and confirm. A turn
|
|
22
|
+
* that dies in between confirms nothing, and cannot release anything either:
|
|
23
|
+
* its claim lapses on the store's clock and the next turn claims again, so the
|
|
24
|
+
* stored conversation does not say "waiting" for good.
|
|
25
|
+
*/
|
|
26
|
+
export const EXPIRY_CLAIM_LEASE_MS = 2 * 60_000;
|
|
27
|
+
export const APPROVAL_WITHDRAW_REASONS = ['superseded', 'stopped'];
|
|
14
28
|
const requestIsOUIs = true;
|
|
15
29
|
const grantIsOUIs = true;
|
|
16
30
|
void requestIsOUIs;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/approvals/types.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AAEH,gFAAgF;AAChF,MAAM,CAAC,MAAM,qBAAqB,GAAG,iBAAiB,CAAC;AAEvD,uFAAuF;AACvF,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,GAAG,MAAM,CAAC;AAClD,2DAA2D;AAC3D,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,GAAG,MAAM,CAAC;AAE/C,MAAM,CAAC,MAAM,iBAAiB,GAA+B,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/approvals/types.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AAEH,gFAAgF;AAChF,MAAM,CAAC,MAAM,qBAAqB,GAAG,iBAAiB,CAAC;AAEvD,uFAAuF;AACvF,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,GAAG,MAAM,CAAC;AAClD,2DAA2D;AAC3D,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,GAAG,MAAM,CAAC;AAE/C,MAAM,CAAC,MAAM,iBAAiB,GAA+B,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AAErG;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC;AAEhE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,GAAG,MAAM,CAAC;AAqDhD,MAAM,CAAC,MAAM,yBAAyB,GAAsC,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;AA8CtG,MAAM,aAAa,GAAmD,IAAI,CAAC;AAC3E,MAAM,WAAW,GAA0C,IAAI,CAAC;AAChE,KAAK,aAAa,CAAC;AACnB,KAAK,WAAW,CAAC"}
|
package/dist/browser.d.ts
CHANGED
package/dist/browser.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC"}
|
package/dist/browser.js
CHANGED
package/dist/browser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC"}
|
package/dist/protocol/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ApprovalRequiredEvent } from '../approvals/types.js';
|
|
2
|
+
import { type TurnStopReason } from '../turns/types.js';
|
|
2
3
|
/**
|
|
3
4
|
* Canonical Socket.IO event names of an agent turn. Declared with their
|
|
4
5
|
* payloads among the platform's events (`PLATFORM_EVENTS`,
|
|
@@ -176,6 +177,11 @@ export interface DoneEvent {
|
|
|
176
177
|
totalTokens: number;
|
|
177
178
|
};
|
|
178
179
|
maxRoundsReached?: boolean;
|
|
180
|
+
/**
|
|
181
|
+
* Set when the turn did not end by itself (ADR-0252): the person stopped it,
|
|
182
|
+
* or a newer message superseded it. What it had produced is stored.
|
|
183
|
+
*/
|
|
184
|
+
stopReason?: TurnStopReason;
|
|
179
185
|
}
|
|
180
186
|
/**
|
|
181
187
|
* Maps a raw Socket.IO event (name + payload) to an AgentProtocolEvent.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/protocol/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;
|
|
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|
5
5
|
import { AGENT_TURN_EVENTS } from '@ouispec/agent-events';
|
|
6
|
+
import { isTurnStopReason } from '../turns/types.js';
|
|
6
7
|
/**
|
|
7
8
|
* Canonical Socket.IO event names of an agent turn. Declared with their
|
|
8
9
|
* payloads among the platform's events (`PLATFORM_EVENTS`,
|
|
@@ -79,6 +80,7 @@ export function parseSocketEvent(event, data, fallbackTurnId) {
|
|
|
79
80
|
turnId,
|
|
80
81
|
messageId: payload.messageId,
|
|
81
82
|
usage: payload.usage,
|
|
83
|
+
...(isTurnStopReason(payload.stopReason) ? { stopReason: payload.stopReason } : {}),
|
|
82
84
|
};
|
|
83
85
|
case AGENT_SOCKET_EVENTS.TURN_ERROR: {
|
|
84
86
|
const errObj = (payload.error ?? payload);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/protocol/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/protocol/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,OAAO,EAAE,gBAAgB,EAAuB,MAAM,mBAAmB,CAAC;AAE1E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,iBAAiB,CAAC;AAIrD,MAAM,CAAC,MAAM,uBAAuB,GAA2B,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;AAElG;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,SAAS,EAAW,CAAC;AAEnG;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAA2D;IAI3F,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,MAAM,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AAQ,EAAE,EAAE,EAAE;gBAClF,SAAS,EAAE,KAAK,CAAC,SAAS,IAAI,CAAC;aAChC,CAAC;QACJ,CAAC;QAED;YACE,OAAO,IAAI,CAAC;IAChB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/turns/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/turns/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stopping a turn (ADR-0252): the shapes the tab, the realtime server, the
|
|
3
|
+
* worker and a host's API exchange when a person stops a running turn, or
|
|
4
|
+
* sends a new message that supersedes it.
|
|
5
|
+
*
|
|
6
|
+
* A stop is a request kept by the realtime server. The worker has no socket:
|
|
7
|
+
* it asks for the request, as it asks for UI answers and approvals.
|
|
8
|
+
*/
|
|
9
|
+
/** The client event a user's socket sends to stop its own running turn. */
|
|
10
|
+
export declare const TURN_STOP_EVENT = "agent:turn_stop";
|
|
11
|
+
/**
|
|
12
|
+
* Why a turn was stopped:
|
|
13
|
+
* - `user_stop`: the person pressed Stop.
|
|
14
|
+
* - `superseded`: a newer message arrived in the conversation, and it runs instead.
|
|
15
|
+
*/
|
|
16
|
+
export type TurnStopReason = 'user_stop' | 'superseded';
|
|
17
|
+
export declare const TURN_STOP_REASONS: readonly TurnStopReason[];
|
|
18
|
+
export declare function isTurnStopReason(value: unknown): value is TurnStopReason;
|
|
19
|
+
/**
|
|
20
|
+
* What the tab sends with `TURN_STOP_EVENT`. A stop from a socket is always
|
|
21
|
+
* the person's own (`user_stop`). `room` is the turn's room, which the tab
|
|
22
|
+
* joined with the turn's room token: being in it is what shows the turn is
|
|
23
|
+
* this user's.
|
|
24
|
+
*/
|
|
25
|
+
export interface TurnStopPayload {
|
|
26
|
+
turnId: string;
|
|
27
|
+
room: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The server's answer to `TURN_STOP_EVENT`.
|
|
31
|
+
* - `requested`: the stop is recorded; the turn's worker hears it and ends the turn.
|
|
32
|
+
* - `already`: a stop was recorded before this one; that one stands.
|
|
33
|
+
*/
|
|
34
|
+
export type TurnStopResult = {
|
|
35
|
+
ok: true;
|
|
36
|
+
stop: 'requested' | 'already';
|
|
37
|
+
} | {
|
|
38
|
+
ok: false;
|
|
39
|
+
reason: 'not_in_turn_room' | 'invalid' | 'unavailable';
|
|
40
|
+
};
|
|
41
|
+
/** The stop the realtime server keeps for a turn, written once. */
|
|
42
|
+
export interface TurnStopRecord {
|
|
43
|
+
turnId: string;
|
|
44
|
+
/** The user who asked, or on whose behalf the host asked. */
|
|
45
|
+
by: string;
|
|
46
|
+
reason: TurnStopReason;
|
|
47
|
+
/** Epoch ms, by the store's clock. */
|
|
48
|
+
at: number;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* How long the server keeps a stop: far longer than any turn runs, so a worker
|
|
52
|
+
* that was slow to start, or whose watch failed and retried, still hears it.
|
|
53
|
+
*/
|
|
54
|
+
export declare const TURN_STOP_RECORD_TTL_MS: number;
|
|
55
|
+
/**
|
|
56
|
+
* A stopped turn's mark on its last stored assistant message. A later turn's
|
|
57
|
+
* history says, after that message's text, that the turn was stopped there.
|
|
58
|
+
*/
|
|
59
|
+
export interface TurnStoppedMarker {
|
|
60
|
+
reason: TurnStopReason;
|
|
61
|
+
/** Epoch ms. */
|
|
62
|
+
at: number;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The line a stopped turn leaves in the conversation: what a later turn's
|
|
66
|
+
* model reads after the stopped message's text, and the whole text of a
|
|
67
|
+
* stopped message that has none (a model provider refuses an empty text
|
|
68
|
+
* block, so a stopped turn that produced nothing still says this).
|
|
69
|
+
*/
|
|
70
|
+
export declare function turnStoppedNote(marker: Pick<TurnStoppedMarker, 'reason'>): string;
|
|
71
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/turns/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,2EAA2E;AAC3E,eAAO,MAAM,eAAe,oBAAoB,CAAC;AAEjD;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,YAAY,CAAC;AAExD,eAAO,MAAM,iBAAiB,EAAE,SAAS,cAAc,EAAgC,CAAC;AAExF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,cAAc,CAExE;AAED;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;GAIG;AACH,MAAM,MAAM,cAAc,GACtB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,WAAW,GAAG,SAAS,CAAA;CAAE,GAC3C;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,kBAAkB,GAAG,SAAS,GAAG,aAAa,CAAA;CAAE,CAAC;AAE1E,mEAAmE;AACnE,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,6DAA6D;IAC7D,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,cAAc,CAAC;IACvB,sCAAsC;IACtC,EAAE,EAAE,MAAM,CAAC;CACZ;AAED;;;GAGG;AACH,eAAO,MAAM,uBAAuB,QAAc,CAAC;AAEnD;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,cAAc,CAAC;IACvB,gBAAgB;IAChB,EAAE,EAAE,MAAM,CAAC;CACZ;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,IAAI,CAAC,iBAAiB,EAAE,QAAQ,CAAC,GAAG,MAAM,CAIjF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stopping a turn (ADR-0252): the shapes the tab, the realtime server, the
|
|
3
|
+
* worker and a host's API exchange when a person stops a running turn, or
|
|
4
|
+
* sends a new message that supersedes it.
|
|
5
|
+
*
|
|
6
|
+
* A stop is a request kept by the realtime server. The worker has no socket:
|
|
7
|
+
* it asks for the request, as it asks for UI answers and approvals.
|
|
8
|
+
*/
|
|
9
|
+
/** The client event a user's socket sends to stop its own running turn. */
|
|
10
|
+
export const TURN_STOP_EVENT = 'agent:turn_stop';
|
|
11
|
+
export const TURN_STOP_REASONS = ['user_stop', 'superseded'];
|
|
12
|
+
export function isTurnStopReason(value) {
|
|
13
|
+
return typeof value === 'string' && TURN_STOP_REASONS.includes(value);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* How long the server keeps a stop: far longer than any turn runs, so a worker
|
|
17
|
+
* that was slow to start, or whose watch failed and retried, still hears it.
|
|
18
|
+
*/
|
|
19
|
+
export const TURN_STOP_RECORD_TTL_MS = 30 * 60_000;
|
|
20
|
+
/**
|
|
21
|
+
* The line a stopped turn leaves in the conversation: what a later turn's
|
|
22
|
+
* model reads after the stopped message's text, and the whole text of a
|
|
23
|
+
* stopped message that has none (a model provider refuses an empty text
|
|
24
|
+
* block, so a stopped turn that produced nothing still says this).
|
|
25
|
+
*/
|
|
26
|
+
export function turnStoppedNote(marker) {
|
|
27
|
+
return marker.reason === 'superseded'
|
|
28
|
+
? '[This turn was stopped here because the person sent a new message. Calls marked "not run" did not run.]'
|
|
29
|
+
: '[The person stopped this turn here. Calls marked "not run" did not run.]';
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/turns/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,2EAA2E;AAC3E,MAAM,CAAC,MAAM,eAAe,GAAG,iBAAiB,CAAC;AASjD,MAAM,CAAC,MAAM,iBAAiB,GAA8B,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;AAExF,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAK,iBAAuC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC/F,CAAC;AAgCD;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,GAAG,MAAM,CAAC;AAYnD;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,MAAyC;IACvE,OAAO,MAAM,CAAC,MAAM,KAAK,YAAY;QACnC,CAAC,CAAC,yGAAyG;QAC3G,CAAC,CAAC,0EAA0E,CAAC;AACjF,CAAC"}
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
import type { AgentProtocolEvent } from '../protocol/index.js';
|
|
14
14
|
import type { ViewAnnotationState } from './api-surface.js';
|
|
15
15
|
import type { ApprovalContinuation, ApprovalGrant } from '../approvals/types.js';
|
|
16
|
+
import type { TurnStoppedMarker } from '../turns/types.js';
|
|
16
17
|
/**
|
|
17
18
|
* Context sent alongside each message. The SDK collects visible annotations
|
|
18
19
|
* and current route automatically; platforms can add custom metadata.
|
|
@@ -131,6 +132,11 @@ export interface AgentStoredMessage {
|
|
|
131
132
|
}> | null;
|
|
132
133
|
toolCallId?: string | null;
|
|
133
134
|
createdAt: string;
|
|
135
|
+
/**
|
|
136
|
+
* Set on the last assistant message of a turn that was stopped (ADR-0252).
|
|
137
|
+
* The panel labels the message; a later turn's history says so after its text.
|
|
138
|
+
*/
|
|
139
|
+
stopped?: TurnStoppedMarker | null;
|
|
134
140
|
}
|
|
135
141
|
/** One stored conversation, with its most recent messages in chronological order. */
|
|
136
142
|
export interface AgentStoredConversation {
|
|
@@ -184,6 +190,17 @@ export interface AgentClientConfig {
|
|
|
184
190
|
socketRoom: string;
|
|
185
191
|
roomToken?: string;
|
|
186
192
|
}>;
|
|
193
|
+
/**
|
|
194
|
+
* Asks the platform's API to stop a turn (ADR-0252 §2.14). The Stop control
|
|
195
|
+
* asks over the socket first; this is used when the socket cannot be reached
|
|
196
|
+
* or the stop is not confirmed in time. The platform checks that the turn is
|
|
197
|
+
* the user's, and records the same stop the socket would have. Optional: a
|
|
198
|
+
* platform without it stops only over the socket.
|
|
199
|
+
*/
|
|
200
|
+
stopTurn?: (params: {
|
|
201
|
+
turnId: string;
|
|
202
|
+
conversationId: string | null;
|
|
203
|
+
}) => Promise<void>;
|
|
187
204
|
/**
|
|
188
205
|
* Hands the user's approval to this tab's OUI runtime (`runtime.grantApproval`
|
|
189
206
|
* in oui-spec), so the approved UI action runs when the worker dispatches it.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-config.d.ts","sourceRoot":"","sources":["../../src/types/client-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"client-config.d.ts","sourceRoot":"","sources":["../../src/types/client-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACjF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAG3D;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;I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name": "@ouispec/agent-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Schema types, entity graph, intent resolution, and protocol definitions for the agent SDK",
|
|
5
5
|
"homepage": "https://github.com/wesreid/oui/tree/main/packages/agent-core#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"ajv": "^8.17.0",
|
|
32
32
|
"yaml": "^2.7.0",
|
|
33
|
-
"@ouispec/agent-events": "^0.
|
|
34
|
-
"@ouispec/contract": "^0.2
|
|
35
|
-
"oui-spec": "^0.
|
|
33
|
+
"@ouispec/agent-events": "^0.7.0",
|
|
34
|
+
"@ouispec/contract": "^0.3.2",
|
|
35
|
+
"oui-spec": "^0.10.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/node": "^22.0.0",
|