@stratusagent/core 0.13.5 → 0.13.7
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/README.md +1 -1
- package/dist/channels.d.ts +661 -0
- package/dist/channels.d.ts.map +1 -0
- package/dist/channels.js +31 -0
- package/dist/channels.js.map +1 -0
- package/dist/executors.d.ts +35 -0
- package/dist/executors.d.ts.map +1 -0
- package/dist/executors.js +64 -0
- package/dist/executors.js.map +1 -0
- package/dist/index.d.ts +211 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +236 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channels.d.ts","sourceRoot":"","sources":["../src/channels.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,eAAe,EACf,QAAQ,EACR,eAAe,EACf,UAAU,EACV,OAAO,EACP,UAAU,EACX,MAAM,YAAY,CAAC;AAEpB;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,mCAAmC;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,sDAAsD;IACtD,YAAY,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7C,iEAAiE;IACjE,IAAI,EAAE,MAAM,CAAC;IACb,kEAAkE;IAClE,aAAa,EAAE,OAAO,CAAC;IACvB,sDAAsD;IACtD,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,+DAA+D;AAC/D,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,EAAE,EAAE,MAAM,CAAC;CACZ;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW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dist/channels.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The stable session id for one conversation: `channel:agent:team:conversation[:thread]`.
|
|
3
|
+
* Stable means resumable — any later message with the same parts lands in
|
|
4
|
+
* the same session, across daemon restarts included. Callers pass
|
|
5
|
+
* `thread_ts ?? ts` as the thread for channel messages (a top-level mention
|
|
6
|
+
* roots its own reply-thread conversation), no thread for a DM's top level,
|
|
7
|
+
* and the thread's root for a reply in a DM thread.
|
|
8
|
+
*/
|
|
9
|
+
export const channelSessionKey = (parts) => {
|
|
10
|
+
const segments = [parts.channel, parts.agentId, parts.team, parts.conversation];
|
|
11
|
+
if (parts.thread) {
|
|
12
|
+
segments.push(parts.thread);
|
|
13
|
+
}
|
|
14
|
+
return segments.join(':');
|
|
15
|
+
};
|
|
16
|
+
/** Whether `senderId` is on the policy's principals list. */
|
|
17
|
+
export const isPrincipal = (policy, senderId) => (policy?.principals ?? []).includes(senderId);
|
|
18
|
+
/**
|
|
19
|
+
* Whether a message from `senderId` may start a turn. No policy admits:
|
|
20
|
+
* there is nobody's list to refuse against, which is the answer from
|
|
21
|
+
* before admission existed.
|
|
22
|
+
*/
|
|
23
|
+
export const admitsSender = (policy, senderId) => policy === undefined || policy.admit !== 'principals' || isPrincipal(policy, senderId);
|
|
24
|
+
/**
|
|
25
|
+
* The trust label a turn from `senderId` carries (`SENDER_TRUST_METADATA_KEY`
|
|
26
|
+
* in `@stratusagent/core`): `user` for a principal, `unknown` for anyone else.
|
|
27
|
+
* Evaluated per message, never per session: a group conversation keys one
|
|
28
|
+
* session for everyone in it.
|
|
29
|
+
*/
|
|
30
|
+
export const senderTrustFor = (policy, senderId) => isPrincipal(policy, senderId) ? 'user' : 'unknown';
|
|
31
|
+
//# sourceMappingURL=channels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channels.js","sourceRoot":"","sources":["../src/channels.ts"],"names":[],"mappings":"AAmmBA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KAA6B,EAAU,EAAE;IACzE,MAAM,QAAQ,GAAG,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC;IAChF,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;QACjB,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC;IACD,OAAO,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC5B,CAAC,CAAC;AAiCF,6DAA6D;AAC7D,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,MAAgC,EAAE,QAAgB,EAAW,EAAE,CACzF,CAAC,MAAM,EAAE,UAAU,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAEhD;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,MAAgC,EAAE,QAAgB,EAAW,EAAE,CAC1F,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,KAAK,KAAK,YAAY,IAAI,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAEzF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAgC,EAAE,QAAgB,EAA2C,EAAE,CAC5H,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type ExecutionContext, type Executor, type JsonValue, type Session, type Tool, type ToolCall, type ToolResult, type TrustLevel } from './index.ts';
|
|
2
|
+
export interface ExecutorResultCallRef {
|
|
3
|
+
id: string;
|
|
4
|
+
toolName: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const normalizeExecutorError: (error: unknown) => string;
|
|
7
|
+
/**
|
|
8
|
+
* A successful result, labelled. `trust` is what the executor resolved from
|
|
9
|
+
* the tool's producer channels (`createTrustMarking`); a caller building a
|
|
10
|
+
* result by hand with no idea where the content came from should say
|
|
11
|
+
* `unknown` rather than take the default, which is the label for a tool
|
|
12
|
+
* that declared nothing and marked nothing — its own work.
|
|
13
|
+
*/
|
|
14
|
+
export declare const successResult: (call: ToolCall | ExecutorResultCallRef, output: JsonValue, trust?: TrustLevel) => ToolResult;
|
|
15
|
+
export declare const failureResult: (call: ToolCall | ExecutorResultCallRef, error: unknown, output?: JsonValue, trust?: TrustLevel) => ToolResult;
|
|
16
|
+
export interface ExecutorDefinition {
|
|
17
|
+
execute(call: ToolCall, tool: Tool, session: Session, context?: ExecutionContext): Promise<ToolResult>;
|
|
18
|
+
}
|
|
19
|
+
export declare const defineExecutor: ({ execute }: ExecutorDefinition) => Executor;
|
|
20
|
+
export interface DirectExecutorErrorContext {
|
|
21
|
+
call: ToolCall;
|
|
22
|
+
tool: Tool;
|
|
23
|
+
session: Session;
|
|
24
|
+
error: unknown;
|
|
25
|
+
}
|
|
26
|
+
export interface DirectExecutorOptions {
|
|
27
|
+
onError?: (context: DirectExecutorErrorContext) => ToolResult | Promise<ToolResult>;
|
|
28
|
+
}
|
|
29
|
+
export declare class DirectExecutor implements Executor {
|
|
30
|
+
private readonly onError?;
|
|
31
|
+
constructor(options?: DirectExecutorOptions);
|
|
32
|
+
execute(call: ToolCall, tool: Tool, session: Session, context?: ExecutionContext): Promise<ToolResult>;
|
|
33
|
+
}
|
|
34
|
+
export declare const createDirectExecutor: (options?: DirectExecutorOptions) => Executor;
|
|
35
|
+
//# sourceMappingURL=executors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executors.d.ts","sourceRoot":"","sources":["../src/executors.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,gBAAgB,EACrB,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,OAAO,EACZ,KAAK,IAAI,EACT,KAAK,QA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AAE,gBAAgB,GAAG,OAAO,CAAC,UAAU,CAAC;CAmB7G;AAED,eAAO,MAAM,oBAAoB,GAAI,UAAS,qBAA0B,KAAG,QAC9C,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { createTrustMarking, leastTrusted, } from "./index.js";
|
|
2
|
+
const toCallRef = (call) => ({
|
|
3
|
+
id: call.id,
|
|
4
|
+
toolName: call.toolName,
|
|
5
|
+
});
|
|
6
|
+
export const normalizeExecutorError = (error) => error instanceof Error ? error.message : String(error);
|
|
7
|
+
/**
|
|
8
|
+
* A successful result, labelled. `trust` is what the executor resolved from
|
|
9
|
+
* the tool's producer channels (`createTrustMarking`); a caller building a
|
|
10
|
+
* result by hand with no idea where the content came from should say
|
|
11
|
+
* `unknown` rather than take the default, which is the label for a tool
|
|
12
|
+
* that declared nothing and marked nothing — its own work.
|
|
13
|
+
*/
|
|
14
|
+
export const successResult = (call, output, trust = 'agent') => {
|
|
15
|
+
const ref = toCallRef(call);
|
|
16
|
+
return {
|
|
17
|
+
callId: ref.id,
|
|
18
|
+
toolName: ref.toolName,
|
|
19
|
+
ok: true,
|
|
20
|
+
output,
|
|
21
|
+
trust,
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export const failureResult = (call, error, output = null, trust = 'agent') => {
|
|
25
|
+
const ref = toCallRef(call);
|
|
26
|
+
return {
|
|
27
|
+
callId: ref.id,
|
|
28
|
+
toolName: ref.toolName,
|
|
29
|
+
ok: false,
|
|
30
|
+
output,
|
|
31
|
+
error: normalizeExecutorError(error),
|
|
32
|
+
trust,
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export const defineExecutor = ({ execute }) => ({
|
|
36
|
+
execute,
|
|
37
|
+
});
|
|
38
|
+
export class DirectExecutor {
|
|
39
|
+
onError;
|
|
40
|
+
constructor(options = {}) {
|
|
41
|
+
this.onError = options.onError;
|
|
42
|
+
}
|
|
43
|
+
async execute(call, tool, session, context) {
|
|
44
|
+
const marking = createTrustMarking(tool, context);
|
|
45
|
+
try {
|
|
46
|
+
const output = await tool.execute(call.input, session, marking.context);
|
|
47
|
+
return successResult(call, output, marking.resolve());
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
if (this.onError) {
|
|
51
|
+
// The tool's channels set the floor: a mapper may lower the label
|
|
52
|
+
// further (it knows what it wrapped) but never raise it — the error
|
|
53
|
+
// it is wrapping may quote a server, and `failureResult`'s default
|
|
54
|
+
// is `agent`, which a mapper reaching for the helper would
|
|
55
|
+
// otherwise hand an `external` tool's error text.
|
|
56
|
+
const mapped = await this.onError({ call, tool, session, error });
|
|
57
|
+
return { ...mapped, trust: leastTrusted(marking.resolve(), mapped.trust ?? 'agent') };
|
|
58
|
+
}
|
|
59
|
+
return failureResult(call, error, null, marking.resolve());
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
export const createDirectExecutor = (options = {}) => new DirectExecutor(options);
|
|
64
|
+
//# sourceMappingURL=executors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executors.js","sourceRoot":"","sources":["../src/executors.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,YAAY,GASb,MAAM,YAAY,CAAC;AAOpB,MAAM,SAAS,GAAG,CAAC,IAAsC,EAAyB,EAAE,CAAC,CAAC;IACpF,EAAE,EAAE,IAAI,CAAC,EAAE;IACX,QAAQ,EAAE,IAAI,CAAC,QAAQ;CACxB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,KAAc,EAAU,EAAE,CAC/D,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAEzD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,IAAsC,EACtC,MAAiB,EACjB,QAAoB,OAAO,EACf,EAAE;IACd,MAAM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,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;gBACjB,kEAAkE;gBAClE,oEAAoE;gBACpE,mEAAmE;gBACnE,2DAA2D;gBAC3D,kDAAkD;gBAClD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;gBAClE,OAAO,EAAE,GAAG,MAAM,EAAE,KAAK,EAAE,YAAY,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,MAAM,CAAC,KAAK,IAAI,OAAO,CAAC,EAAE,CAAC;YACxF,CAAC;YAED,OAAO,aAAa,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;CACF;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,UAAiC,EAAE,EAAY,EAAE,CACpF,IAAI,cAAc,CAAC,OAAO,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1590,6 +1590,21 @@ export interface UsageRecord extends TokenUsage {
|
|
|
1590
1590
|
turnId: string;
|
|
1591
1591
|
provider: string;
|
|
1592
1592
|
model?: string;
|
|
1593
|
+
/**
|
|
1594
|
+
* Unique to this one provider call, assigned when the record is made and
|
|
1595
|
+
* saved with it. What lets a consumer that meters spend outside the
|
|
1596
|
+
* session (a usage ledger) count each call exactly once however many
|
|
1597
|
+
* times it sees it: from the `session.usage` announcement, and again from
|
|
1598
|
+
* the saved session after a crash that came between the save and the
|
|
1599
|
+
* announcement. Absent on records saved before it existed.
|
|
1600
|
+
*/
|
|
1601
|
+
id?: string;
|
|
1602
|
+
/**
|
|
1603
|
+
* When the call's usage was recorded, ISO 8601. A consumer that learns of
|
|
1604
|
+
* a call late (reconciling a session after a crash) still files it under
|
|
1605
|
+
* the day it was spent. Absent on records saved before it existed.
|
|
1606
|
+
*/
|
|
1607
|
+
at?: string;
|
|
1593
1608
|
}
|
|
1594
1609
|
/**
|
|
1595
1610
|
* `TokenUsage.inputTokens` for a vendor that reports its prompt count
|
|
@@ -1814,6 +1829,18 @@ export interface ProviderRequest {
|
|
|
1814
1829
|
* turn that actually succeeded goes uncounted.
|
|
1815
1830
|
*/
|
|
1816
1831
|
onUsage?: (usage: ProviderCallUsage) => void;
|
|
1832
|
+
/**
|
|
1833
|
+
* For a provider that makes another model call inside one `generate` on
|
|
1834
|
+
* its own decision, the fallback wrapper's switch being the live example:
|
|
1835
|
+
* await this before that call, naming the provider about to answer. The
|
|
1836
|
+
* runner announces the usage reported so far, then asks the host's
|
|
1837
|
+
* `ProviderCallGuard`s, so a budget the first call just spent is read
|
|
1838
|
+
* before the next one starts. It resolves to allow the call and throws to
|
|
1839
|
+
* refuse it; let the error propagate, because a refusal ends the turn.
|
|
1840
|
+
*
|
|
1841
|
+
* Not for a harness's own inner calls, which this interface never sees.
|
|
1842
|
+
*/
|
|
1843
|
+
guardCall?: (provider: string) => Promise<void>;
|
|
1817
1844
|
/**
|
|
1818
1845
|
* For a provider that runs its own tool loop (the harness runtimes): ask,
|
|
1819
1846
|
* when its inner budget runs out mid-work, whether to carry on with a
|
|
@@ -1851,8 +1878,46 @@ export interface ProviderResponse {
|
|
|
1851
1878
|
}
|
|
1852
1879
|
export interface ModelProvider {
|
|
1853
1880
|
name: string;
|
|
1881
|
+
/**
|
|
1882
|
+
* For a provider that hands a session's calls to another provider while
|
|
1883
|
+
* keeping its own `name` (the fallback wrapper, once a session has
|
|
1884
|
+
* switched): the name of the provider that answers this session's next
|
|
1885
|
+
* call. The `ProviderCallGuard`s are told it, so a rule about one model
|
|
1886
|
+
* holds whichever wrapper it sits behind. Absent means `name`.
|
|
1887
|
+
*/
|
|
1888
|
+
nameFor?(session: Session): string;
|
|
1854
1889
|
generate(request: ProviderRequest): Promise<ProviderResponse>;
|
|
1855
1890
|
}
|
|
1891
|
+
/** Who is about to spend a provider call: what a `ProviderCallGuard` is asked about. */
|
|
1892
|
+
export interface ProviderCallCheck {
|
|
1893
|
+
agentId: string;
|
|
1894
|
+
sessionId: string;
|
|
1895
|
+
/**
|
|
1896
|
+
* The provider about to answer, by name: the runner's provider, or the
|
|
1897
|
+
* one it says answers this session (`ModelProvider.nameFor`). Under a
|
|
1898
|
+
* configured fallback that is the primary until the session switches and
|
|
1899
|
+
* the fallback after. A switch inside a call asks again before the
|
|
1900
|
+
* fallback's call, naming the fallback (`ProviderRequest.guardCall`).
|
|
1901
|
+
*/
|
|
1902
|
+
provider: string;
|
|
1903
|
+
}
|
|
1904
|
+
/**
|
|
1905
|
+
* A host's say over each provider call before it is made: a token budget
|
|
1906
|
+
* is the case it exists for. Resolving allows the call. Throwing refuses
|
|
1907
|
+
* it and fails the turn: a `HostRefusalError` for a refusal made on purpose,
|
|
1908
|
+
* whose message is a sentence for the person in the conversation, and any
|
|
1909
|
+
* other error for a guard that could not decide, which refuses as well,
|
|
1910
|
+
* because a budget that cannot be read is not a budget that said yes.
|
|
1911
|
+
*
|
|
1912
|
+
* Asked once per `ModelProvider.generate`, which is one model call for the
|
|
1913
|
+
* kernel-loop adapters and one Stratus turn for a harness running its own
|
|
1914
|
+
* inner loop, and again before any further call a provider makes inside one
|
|
1915
|
+
* `generate` and asks about through `ProviderRequest.guardCall` (the
|
|
1916
|
+
* fallback model's call after the primary fails). The usage of every
|
|
1917
|
+
* earlier call has been announced (`session.usage`) before a guard is asked
|
|
1918
|
+
* about the next one.
|
|
1919
|
+
*/
|
|
1920
|
+
export type ProviderCallGuard = (check: ProviderCallCheck) => Promise<void> | void;
|
|
1856
1921
|
/**
|
|
1857
1922
|
* What a scrubbed subprocess inherits by name when its operator granted
|
|
1858
1923
|
* nothing else — the replacement-environment treatment `tool-shell`
|
|
@@ -1870,7 +1935,9 @@ export declare const DEFAULT_SUBPROCESS_PASS_ENV: readonly string[];
|
|
|
1870
1935
|
/**
|
|
1871
1936
|
* Ambient context for one tool execution. The abort signal is the turn's:
|
|
1872
1937
|
* executors kill in-flight subprocesses on abort, and long-running tools
|
|
1873
|
-
* should observe it too.
|
|
1938
|
+
* should observe it too. One that does not is left behind a short grace
|
|
1939
|
+
* after the abort (`untilStoppedFor`), still running, with a result that
|
|
1940
|
+
* says so.
|
|
1874
1941
|
*/
|
|
1875
1942
|
export interface ExecutionContext {
|
|
1876
1943
|
signal?: AbortSignal;
|
|
@@ -2626,6 +2693,36 @@ export type StratusEvent = {
|
|
|
2626
2693
|
type: 'session.failed';
|
|
2627
2694
|
sessionId: string;
|
|
2628
2695
|
error: string;
|
|
2696
|
+
/**
|
|
2697
|
+
* True when the host stopped the turn on purpose (`HostRefusalError`):
|
|
2698
|
+
* `error` is then a sentence meant for the person in the conversation,
|
|
2699
|
+
* and a renderer shows it as it is rather than as a malfunction.
|
|
2700
|
+
*/
|
|
2701
|
+
refused?: true;
|
|
2702
|
+
}
|
|
2703
|
+
/**
|
|
2704
|
+
* Usage a provider call just reported, as it lands: the records added to
|
|
2705
|
+
* the session since the last announcement, in the order they were
|
|
2706
|
+
* recorded. A harness reporting inner calls through the sink is announced
|
|
2707
|
+
* as each report arrives, while its `generate` is still running, so a
|
|
2708
|
+
* daemon that dies mid-call has already told a ledger what was spent.
|
|
2709
|
+
*
|
|
2710
|
+
* Per call rather than once per turn because a turn can make many calls,
|
|
2711
|
+
* and a host enforcing a budget has to know what the call before this one
|
|
2712
|
+
* spent before it allows the next. `session.completed` arrives too late
|
|
2713
|
+
* for that and is never sent for a turn that failed. Emitted for a failed
|
|
2714
|
+
* attempt too, whenever it reported anything: the tokens of a call that
|
|
2715
|
+
* threw were still spent. `agentId` rides along so a consumer
|
|
2716
|
+
* attributing spend to an agent needs no store read.
|
|
2717
|
+
*
|
|
2718
|
+
* Counts and attribution only, the same records `session.completed`
|
|
2719
|
+
* carries, ids included.
|
|
2720
|
+
*/
|
|
2721
|
+
| {
|
|
2722
|
+
type: 'session.usage';
|
|
2723
|
+
sessionId: string;
|
|
2724
|
+
agentId: string;
|
|
2725
|
+
records: UsageRecord[];
|
|
2629
2726
|
}
|
|
2630
2727
|
/**
|
|
2631
2728
|
* The session's trust label went down. `source` names what lowered it —
|
|
@@ -2768,11 +2865,11 @@ export interface ProviderContribution {
|
|
|
2768
2865
|
streams?: boolean;
|
|
2769
2866
|
}
|
|
2770
2867
|
/**
|
|
2771
|
-
* The slice of a channel adapter the kernel holds: structurally
|
|
2772
|
-
*
|
|
2773
|
-
*
|
|
2774
|
-
*
|
|
2775
|
-
*
|
|
2868
|
+
* The slice of a channel adapter the kernel holds: structurally the
|
|
2869
|
+
* `ChannelAdapter` in `channels.ts`, declared on its own because it
|
|
2870
|
+
* predates that contract moving into core (the gateway keeps a copy for
|
|
2871
|
+
* the same reason). `name` is the channel kind (`slack`, `discord`); the
|
|
2872
|
+
* gateway it is started with is the host's.
|
|
2776
2873
|
*/
|
|
2777
2874
|
export interface ChannelAdapterLike {
|
|
2778
2875
|
name: string;
|
|
@@ -2786,7 +2883,7 @@ export interface ChannelAdapterLike {
|
|
|
2786
2883
|
}): Promise<{
|
|
2787
2884
|
post(text: string): Promise<unknown>;
|
|
2788
2885
|
}>;
|
|
2789
|
-
/** See
|
|
2886
|
+
/** See `ChannelAdapter.readConversation`. */
|
|
2790
2887
|
readConversation?(request: {
|
|
2791
2888
|
agentId: string;
|
|
2792
2889
|
conversation: string;
|
|
@@ -2794,6 +2891,7 @@ export interface ChannelAdapterLike {
|
|
|
2794
2891
|
after?: string;
|
|
2795
2892
|
before?: string;
|
|
2796
2893
|
limit: number;
|
|
2894
|
+
sessionId?: string;
|
|
2797
2895
|
}): Promise<{
|
|
2798
2896
|
messages: Array<{
|
|
2799
2897
|
id: string;
|
|
@@ -2806,11 +2904,40 @@ export interface ChannelAdapterLike {
|
|
|
2806
2904
|
files?: string[];
|
|
2807
2905
|
}>;
|
|
2808
2906
|
more: boolean;
|
|
2907
|
+
bookmarks?: Array<{
|
|
2908
|
+
title: string;
|
|
2909
|
+
link: string;
|
|
2910
|
+
}>;
|
|
2911
|
+
bookmarksUnavailable?: string;
|
|
2912
|
+
bookmarksOmitted?: number;
|
|
2809
2913
|
}>;
|
|
2810
|
-
/** See
|
|
2914
|
+
/** See `ChannelAdapter.createConversation`. */
|
|
2915
|
+
createConversation?(request: {
|
|
2916
|
+
agentId: string;
|
|
2917
|
+
name: string;
|
|
2918
|
+
private?: boolean;
|
|
2919
|
+
topic?: string;
|
|
2920
|
+
purpose?: string;
|
|
2921
|
+
invite?: string[];
|
|
2922
|
+
}): Promise<{
|
|
2923
|
+
conversation: string;
|
|
2924
|
+
name: string;
|
|
2925
|
+
invited: string[];
|
|
2926
|
+
notInvited: Array<{
|
|
2927
|
+
who: string;
|
|
2928
|
+
reason: string;
|
|
2929
|
+
}>;
|
|
2930
|
+
notSet: Array<{
|
|
2931
|
+
field: 'topic' | 'purpose';
|
|
2932
|
+
reason: string;
|
|
2933
|
+
}>;
|
|
2934
|
+
}>;
|
|
2935
|
+
/** See `ChannelAdapter.accountFor`. */
|
|
2811
2936
|
accountFor?(agentId: string): string | undefined;
|
|
2812
|
-
/** See
|
|
2937
|
+
/** See `ChannelAdapter.conversationKindFor`. */
|
|
2813
2938
|
conversationKindFor?(agentId: string, conversation: string): Promise<'channel' | 'direct' | undefined>;
|
|
2939
|
+
/** See `ChannelAdapter.sessionConversation`. */
|
|
2940
|
+
sessionConversation?(agentId: string, sessionId: string): string | undefined;
|
|
2814
2941
|
}
|
|
2815
2942
|
/**
|
|
2816
2943
|
* A channel contributed by a plugin: the adapter plus the agents it
|
|
@@ -3269,6 +3396,18 @@ export interface PluginContext {
|
|
|
3269
3396
|
* `setup` naming it.
|
|
3270
3397
|
*/
|
|
3271
3398
|
fleet?: FleetReader;
|
|
3399
|
+
/**
|
|
3400
|
+
* Registers a guard the host asks before every provider call. See
|
|
3401
|
+
* {@link ProviderCallGuard}. A host passing it enforces what is
|
|
3402
|
+
* registered for every agent it runs, sub-agents included. A host that
|
|
3403
|
+
* omits it cannot enforce one, and a plugin that needs it (a budget) must
|
|
3404
|
+
* fail its `setup` naming it: a limit nothing enforces must not report
|
|
3405
|
+
* itself loaded.
|
|
3406
|
+
*/
|
|
3407
|
+
providerCalls?: ProviderCallGuardHandle;
|
|
3408
|
+
}
|
|
3409
|
+
export interface ProviderCallGuardHandle {
|
|
3410
|
+
register(guard: ProviderCallGuard): void;
|
|
3272
3411
|
}
|
|
3273
3412
|
export interface Plugin {
|
|
3274
3413
|
name: string;
|
|
@@ -3616,12 +3755,23 @@ export declare const isLanguageTag: (value: unknown) => value is string;
|
|
|
3616
3755
|
*
|
|
3617
3756
|
* The accuracy rules are here for the same reason, each after an incident:
|
|
3618
3757
|
* an agent with no Slack tool insisted it had no Slack connection, and
|
|
3619
|
-
* agents reported work as done that had only been drafted. The
|
|
3620
|
-
*
|
|
3621
|
-
*
|
|
3622
|
-
*
|
|
3623
|
-
*
|
|
3624
|
-
*
|
|
3758
|
+
* agents reported work as done that had only been drafted. The
|
|
3759
|
+
* look-before-you-ask pair is there because a conversation's session holds
|
|
3760
|
+
* its own messages and a slice of memory, nothing more: when work moved to
|
|
3761
|
+
* a new channel, the agent's session there asked the person what its own
|
|
3762
|
+
* earlier thread and files already said. Pointers, not a brief at session
|
|
3763
|
+
* open, because the thread and the file were both in reach and nothing said
|
|
3764
|
+
* to look. What it finds is linked, or asked about before it is repeated,
|
|
3765
|
+
* unless it can tell everyone in the room could already see it. The room
|
|
3766
|
+
* context gives only this room's kind and size, and a read returns no
|
|
3767
|
+
* membership, so the agent cannot check another conversation's audience; a
|
|
3768
|
+
* link is checked by the channel itself, and a file cannot be linked, so it
|
|
3769
|
+
* asks. The language rule is here because the default persona is not: a
|
|
3770
|
+
* custom soul replaces it, and an agent wrote "favour" and "licence" into
|
|
3771
|
+
* American website copy because nothing shared said which English. A pasted
|
|
3772
|
+
* British paragraph is not a setting, so the rule says a task or a client's
|
|
3773
|
+
* style guide decides one deliverable and nothing is inferred from source
|
|
3774
|
+
* text.
|
|
3625
3775
|
*
|
|
3626
3776
|
* The last sentence lets the soul and the person override length, format,
|
|
3627
3777
|
* and language, and deliberately nothing else: a style preference never
|
|
@@ -3924,6 +4074,29 @@ export interface ObserveInput {
|
|
|
3924
4074
|
* shorten. A provider that never throws this behaves exactly as it did.
|
|
3925
4075
|
*/
|
|
3926
4076
|
export declare class ContextOverflowError extends Error {
|
|
4077
|
+
/** Recognized across copies of core: a provider package carries its own. */
|
|
4078
|
+
static [Symbol.hasInstance](value: unknown): boolean;
|
|
4079
|
+
constructor(message: string);
|
|
4080
|
+
}
|
|
4081
|
+
/**
|
|
4082
|
+
* A turn the host stopped on purpose (a spent token budget) rather than
|
|
4083
|
+
* one that broke.
|
|
4084
|
+
*
|
|
4085
|
+
* A kernel type because layers that know nothing of budgets have to treat
|
|
4086
|
+
* it differently from every other failure. A fallback provider must not
|
|
4087
|
+
* answer instead: the limit applies to the agent, not to one model, and a
|
|
4088
|
+
* silent switch would spend what the limit exists to stop while hiding
|
|
4089
|
+
* that it was reached. And a channel must not frame it as something going
|
|
4090
|
+
* wrong: the message is a sentence written for the person reading it,
|
|
4091
|
+
* naming what ran out and what changes it, and `session.failed` says so
|
|
4092
|
+
* with `refused`.
|
|
4093
|
+
*
|
|
4094
|
+
* Thrown by a `ProviderCallGuard`, or subclassed by whoever refuses; the
|
|
4095
|
+
* kernel only ever asks `instanceof`.
|
|
4096
|
+
*/
|
|
4097
|
+
export declare class HostRefusalError extends Error {
|
|
4098
|
+
/** Recognized across copies of core: a plugin package refuses with its own. */
|
|
4099
|
+
static [Symbol.hasInstance](value: unknown): boolean;
|
|
3927
4100
|
constructor(message: string);
|
|
3928
4101
|
}
|
|
3929
4102
|
/**
|
|
@@ -3986,6 +4159,8 @@ export declare const raiseContextFloor: (session: Session) => boolean;
|
|
|
3986
4159
|
* distinguishable from a genuine failure.
|
|
3987
4160
|
*/
|
|
3988
4161
|
export declare class RunAbortedError extends Error {
|
|
4162
|
+
/** Recognized across copies of core: a channel package aborts with its own. */
|
|
4163
|
+
static [Symbol.hasInstance](value: unknown): boolean;
|
|
3989
4164
|
constructor(message?: string);
|
|
3990
4165
|
}
|
|
3991
4166
|
/**
|
|
@@ -4065,6 +4240,13 @@ export interface AgentRunnerOptions {
|
|
|
4065
4240
|
* runs, tests) keep the simpler non-streaming provider path.
|
|
4066
4241
|
*/
|
|
4067
4242
|
streaming?: boolean;
|
|
4243
|
+
/**
|
|
4244
|
+
* Asked, in order, before every provider call; see `ProviderCallGuard`.
|
|
4245
|
+
* Read on each call, so a host may add to the list after constructing
|
|
4246
|
+
* the runner. A host that omits it puts no limit on model calls beyond
|
|
4247
|
+
* `maxTurns`.
|
|
4248
|
+
*/
|
|
4249
|
+
providerCallGuards?: readonly ProviderCallGuard[];
|
|
4068
4250
|
}
|
|
4069
4251
|
export declare const inputProblem: (schema: JsonObject | undefined, input: JsonValue, where?: string, depth?: number) => string | undefined;
|
|
4070
4252
|
export declare const DEFAULT_MAX_TURNS = 40;
|
|
@@ -4178,6 +4360,18 @@ export declare class AgentRunner {
|
|
|
4178
4360
|
* retried call to be counted once, twice, or not at all.
|
|
4179
4361
|
*/
|
|
4180
4362
|
private recordUsage;
|
|
4363
|
+
/**
|
|
4364
|
+
* Emit `session.usage` for the records added to the session since
|
|
4365
|
+
* `recordedBefore`.
|
|
4366
|
+
*
|
|
4367
|
+
* The loop drains these before the next provider call, which is the
|
|
4368
|
+
* point: a host that meters spend from this event has seen every earlier
|
|
4369
|
+
* call's tokens before a guard is asked to allow another one. Copies, so
|
|
4370
|
+
* a subscriber cannot edit the session's accounting through the event.
|
|
4371
|
+
*/
|
|
4372
|
+
private announceUsage;
|
|
4373
|
+
/** Ask every guard about the call about to be made; the first refusal throws. */
|
|
4374
|
+
private guardProviderCall;
|
|
4181
4375
|
/**
|
|
4182
4376
|
* The allowlist entries this session's agent is held to, or undefined for
|
|
4183
4377
|
* no limit. Entries, not a name set: `fs.*` is an entry, and matching is
|
|
@@ -4265,4 +4459,6 @@ export declare class AgentRunner {
|
|
|
4265
4459
|
private checkpointPendingApproval;
|
|
4266
4460
|
private executeToolCall;
|
|
4267
4461
|
}
|
|
4462
|
+
export { createDirectExecutor, defineExecutor, DirectExecutor, failureResult, normalizeExecutorError, successResult, type DirectExecutorErrorContext, type DirectExecutorOptions, type ExecutorDefinition, type ExecutorResultCallRef, } from './executors.ts';
|
|
4463
|
+
export { admitsSender, channelSessionKey, isPrincipal, senderTrustFor, type AdmitPolicy, type ChannelAdapter, type ChannelCredentialRequest, type ChannelSessionKeyParts, type ConversationBookmark, type ConversationCreateRequest, type ConversationCreateResult, type ConversationMessage, type ConversationReadRequest, type ConversationReadResult, type GatewayLike, type InboundMessage, type OutboundAddress, type OutboundConnection, type OutboundMessageRef, type SenderPolicy, type SessionRouting, } from './channels.ts';
|
|
4268
4464
|
//# sourceMappingURL=index.d.ts.map
|