@byfriends/sdk 0.2.4 → 0.3.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/LICENSE +28 -0
- package/dist/index.d.mts +48 -4
- package/dist/index.mjs +566 -574
- package/package.json +18 -24
package/LICENSE
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
BYF PROPRIETARY LICENSE
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026-2027 ByronFinn
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted to copy and redistribute this software in its
|
|
6
|
+
unmodified form, without charge. This permission does not extend to modified
|
|
7
|
+
versions of the software.
|
|
8
|
+
|
|
9
|
+
Local modification of this software for personal use is permitted, provided
|
|
10
|
+
that such modifications are not distributed to third parties.
|
|
11
|
+
|
|
12
|
+
Restrictions:
|
|
13
|
+
1. You may NOT redistribute modified versions of this software.
|
|
14
|
+
2. You may NOT use this software for commercial purposes.
|
|
15
|
+
3. You may NOT sublicense, sell, or offer this software as a service.
|
|
16
|
+
|
|
17
|
+
This software is source-available but NOT open source. The source code is
|
|
18
|
+
made publicly visible for review purposes only.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
28
|
+
For questions about licensing, contact: https://github.com/ByronFinn/byf/issues
|
package/dist/index.d.mts
CHANGED
|
@@ -140,6 +140,13 @@ declare interface AgentMeta {
|
|
|
140
140
|
readonly homedir: string;
|
|
141
141
|
readonly type: AgentType;
|
|
142
142
|
readonly parentAgentId: string | null;
|
|
143
|
+
/**
|
|
144
|
+
* The parent agent's tool-call id that spawned this agent. Absent for the
|
|
145
|
+
* main agent and for sessions persisted before this field existed. The TUI
|
|
146
|
+
* uses it on resume to map a main-agent `Agent` tool-call back to its child
|
|
147
|
+
* agent's activity (the child's own replay/usage/text).
|
|
148
|
+
*/
|
|
149
|
+
readonly parentToolCallId?: string | undefined;
|
|
143
150
|
}
|
|
144
151
|
|
|
145
152
|
declare type AgentRecord = {
|
|
@@ -326,6 +333,7 @@ export declare interface ApplyCatalogProviderOptions {
|
|
|
326
333
|
|
|
327
334
|
export declare function applyProviderConfig(config: ConfigShape, options: {
|
|
328
335
|
readonly name: string;
|
|
336
|
+
readonly type?: string | undefined;
|
|
329
337
|
readonly baseUrl: string;
|
|
330
338
|
readonly apiKey: string;
|
|
331
339
|
readonly models: readonly ModelInfo[];
|
|
@@ -393,6 +401,7 @@ export declare type BackgroundConfig = z.infer<typeof BackgroundConfigSchema>;
|
|
|
393
401
|
|
|
394
402
|
declare const BackgroundConfigSchema: z.ZodObject<{
|
|
395
403
|
maxRunningTasks: z.ZodOptional<z.ZodNumber>;
|
|
404
|
+
maxConcurrentSubagents: z.ZodOptional<z.ZodNumber>;
|
|
396
405
|
keepAliveOnExit: z.ZodOptional<z.ZodBoolean>;
|
|
397
406
|
killGracePeriodMs: z.ZodOptional<z.ZodNumber>;
|
|
398
407
|
agentTaskTimeoutS: z.ZodOptional<z.ZodNumber>;
|
|
@@ -653,7 +662,7 @@ declare class BackgroundProcessManager {
|
|
|
653
662
|
/** Drop a persisted task from disk and ghost map. */
|
|
654
663
|
forgetTask(taskId: string): Promise<void>;
|
|
655
664
|
/**
|
|
656
|
-
* Persist the current state of a live
|
|
665
|
+
* Persist the current state of a live TaskEntry. Called from
|
|
657
666
|
* `register()` and the lifecycle finally block. No-op unless attached.
|
|
658
667
|
*/
|
|
659
668
|
private persistLive;
|
|
@@ -675,7 +684,7 @@ export declare interface BackgroundTaskInfo {
|
|
|
675
684
|
readonly command: string;
|
|
676
685
|
readonly description: string;
|
|
677
686
|
readonly status: BackgroundTaskStatus;
|
|
678
|
-
readonly pid: number;
|
|
687
|
+
readonly pid: number | null;
|
|
679
688
|
readonly exitCode: number | null;
|
|
680
689
|
readonly startedAt: number;
|
|
681
690
|
readonly endedAt: number | null;
|
|
@@ -1217,6 +1226,7 @@ declare const ByfConfigPatchSchema: z.ZodObject<{
|
|
|
1217
1226
|
}, z.core.$strip>>;
|
|
1218
1227
|
background: z.ZodOptional<z.ZodObject<{
|
|
1219
1228
|
maxRunningTasks: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
1229
|
+
maxConcurrentSubagents: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
1220
1230
|
keepAliveOnExit: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
|
|
1221
1231
|
killGracePeriodMs: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
1222
1232
|
agentTaskTimeoutS: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
@@ -1354,6 +1364,7 @@ declare const ByfConfigSchema: z.ZodObject<{
|
|
|
1354
1364
|
}, z.core.$strip>>;
|
|
1355
1365
|
background: z.ZodOptional<z.ZodObject<{
|
|
1356
1366
|
maxRunningTasks: z.ZodOptional<z.ZodNumber>;
|
|
1367
|
+
maxConcurrentSubagents: z.ZodOptional<z.ZodNumber>;
|
|
1357
1368
|
keepAliveOnExit: z.ZodOptional<z.ZodBoolean>;
|
|
1358
1369
|
killGracePeriodMs: z.ZodOptional<z.ZodNumber>;
|
|
1359
1370
|
agentTaskTimeoutS: z.ZodOptional<z.ZodNumber>;
|
|
@@ -1880,6 +1891,12 @@ declare class ContextMemory implements RecordRestoreHandler {
|
|
|
1880
1891
|
get tokenCountWithPending(): number;
|
|
1881
1892
|
get history(): readonly ContextMessage[];
|
|
1882
1893
|
get messages(): Message[];
|
|
1894
|
+
/**
|
|
1895
|
+
* Project history into provider-ready messages, optionally with
|
|
1896
|
+
* ephemeral injections (e.g. timestamp, permission mode) appended
|
|
1897
|
+
* at the `'before_user'` position.
|
|
1898
|
+
*/
|
|
1899
|
+
getMessages(ephemeral?: readonly EphemeralInjection[]): Message[];
|
|
1883
1900
|
applyObservationMasking(config?: MaskingConfig): MaskingResult;
|
|
1884
1901
|
applyPruning(config?: {
|
|
1885
1902
|
effectiveCapacityRatio?: number;
|
|
@@ -1990,6 +2007,12 @@ declare interface Environment {
|
|
|
1990
2007
|
readonly shellPath: string;
|
|
1991
2008
|
}
|
|
1992
2009
|
|
|
2010
|
+
declare interface EphemeralInjection {
|
|
2011
|
+
kind: 'memory_recall' | 'system_reminder' | 'pending_notification';
|
|
2012
|
+
content: string | Record<string, unknown>;
|
|
2013
|
+
position?: 'before_user' | 'after_system';
|
|
2014
|
+
}
|
|
2015
|
+
|
|
1993
2016
|
/**
|
|
1994
2017
|
* Error codes for Byf Core's public error protocol.
|
|
1995
2018
|
*
|
|
@@ -2171,6 +2194,16 @@ export declare function fetchCatalog(url: string, signal?: AbortSignal, fetchImp
|
|
|
2171
2194
|
|
|
2172
2195
|
export declare function fetchModels(baseUrl: string, apiKey: string, fetchImpl?: typeof fetch, signal?: AbortSignal): Promise<ModelInfo[]>;
|
|
2173
2196
|
|
|
2197
|
+
/**
|
|
2198
|
+
* Lists models from a provider using its native wire-type endpoint. Dispatches
|
|
2199
|
+
* per `type` so each protocol gets its correct auth header and response shape.
|
|
2200
|
+
* `openai-completions` and `openai_responses` share the OpenAI-compatible
|
|
2201
|
+
* `/models` endpoint; `anthropic` uses its native `x-api-key` endpoint with
|
|
2202
|
+
* pagination. Other types have dedicated native fetchers (added in
|
|
2203
|
+
* later slices).
|
|
2204
|
+
*/
|
|
2205
|
+
export declare function fetchModelsByType(type: string, baseUrl: string, apiKey: string, fetchImpl?: typeof fetch, signal?: AbortSignal): Promise<ModelInfo[]>;
|
|
2206
|
+
|
|
2174
2207
|
/**
|
|
2175
2208
|
* Searches all providers in the catalog for a model whose ID matches
|
|
2176
2209
|
* `modelId` (prefix + separator boundary). Returns the first match.
|
|
@@ -2513,6 +2546,7 @@ declare class InjectionManager {
|
|
|
2513
2546
|
private readonly injectors;
|
|
2514
2547
|
constructor(agent: Agent);
|
|
2515
2548
|
inject(): Promise<void>;
|
|
2549
|
+
getEphemeralInjections(): readonly EphemeralInjection[];
|
|
2516
2550
|
onContextClear(): void;
|
|
2517
2551
|
onContextCompacted(compactedCount: number): void;
|
|
2518
2552
|
}
|
|
@@ -3930,6 +3964,13 @@ export declare interface ResumedAgentState {
|
|
|
3930
3964
|
readonly tools: readonly ToolInfo[];
|
|
3931
3965
|
readonly toolStore?: Readonly<Record<string, unknown>>;
|
|
3932
3966
|
readonly background: readonly BackgroundTaskInfo[];
|
|
3967
|
+
/**
|
|
3968
|
+
* For sub-agents: the parent agent's tool-call id that spawned this agent.
|
|
3969
|
+
* Absent for the main agent and for sessions persisted before this field
|
|
3970
|
+
* existed. The TUI uses it to attach a resumed main-agent `Agent` tool-call
|
|
3971
|
+
* to this child's activity (replay/usage/text).
|
|
3972
|
+
*/
|
|
3973
|
+
readonly parentToolCallId?: string | undefined;
|
|
3933
3974
|
}
|
|
3934
3975
|
|
|
3935
3976
|
export declare type ResumedSessionState = Pick<ResumeSessionResult, 'sessionMetadata' | 'agents' | 'warning'>;
|
|
@@ -4243,7 +4284,7 @@ declare class Session_2 {
|
|
|
4243
4284
|
}>;
|
|
4244
4285
|
close(): Promise<void>;
|
|
4245
4286
|
private stopBackgroundTasksOnExit;
|
|
4246
|
-
createAgent(config: Partial<AgentConfig>, profile?: ResolvedAgentProfile, parentAgentId?: string | undefined): Promise<{
|
|
4287
|
+
createAgent(config: Partial<AgentConfig>, profile?: ResolvedAgentProfile, parentAgentId?: string | undefined, parentToolCallId?: string | undefined): Promise<{
|
|
4247
4288
|
readonly id: string;
|
|
4248
4289
|
readonly agent: Agent;
|
|
4249
4290
|
}>;
|
|
@@ -4384,10 +4425,13 @@ declare class SessionSubagentHost {
|
|
|
4384
4425
|
private readonly ownerAgentId;
|
|
4385
4426
|
readonly backgroundTaskTimeoutMs?: number | undefined;
|
|
4386
4427
|
private readonly activeChildren;
|
|
4387
|
-
|
|
4428
|
+
/** Maximum concurrent subagents; exposed for testing and config diagnostics. */
|
|
4429
|
+
readonly maxConcurrentSubagents: number;
|
|
4430
|
+
constructor(session: Session_2, ownerAgentId: string, backgroundTaskTimeoutMs?: number | undefined, maxConcurrentSubagents?: number | undefined);
|
|
4388
4431
|
spawn(profileName: string, options: RunSubagentOptions): Promise<SubagentHandle>;
|
|
4389
4432
|
resume(agentId: string, options: RunSubagentOptions): Promise<SubagentHandle>;
|
|
4390
4433
|
cancelAll(): void;
|
|
4434
|
+
private assertCanSpawn;
|
|
4391
4435
|
getProfileName(agentId: string): string | undefined;
|
|
4392
4436
|
private resolveProfile;
|
|
4393
4437
|
private runChild;
|