@lobu/runtime-device 23.0.0 → 24.0.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/component.json +1 -1
- package/dist/dependencies.bun.lock +30 -27
- package/npm-shrinkwrap.json +131 -115
- package/package.json +2 -1
- package/vendor/cli/dist/bundled-skills/lobu/SKILL.md +73 -0
- package/vendor/cli/dist/commands/_lib/apply/apply-cmd.js +9 -11
- package/vendor/cli/dist/commands/_lib/apply/client.d.ts +3 -11
- package/vendor/cli/dist/commands/_lib/apply/client.js +3 -3
- package/vendor/cli/dist/commands/_lib/apply/desired-state.d.ts +0 -6
- package/vendor/cli/dist/commands/_lib/apply/desired-state.js +6 -15
- package/vendor/cli/dist/commands/_lib/apply/diff.js +1 -0
- package/vendor/cli/dist/commands/_lib/apply/map-config.js +8 -0
- package/vendor/cli/dist/commands/_lib/view-bundler.d.ts +2 -9
- package/vendor/cli/dist/commands/_lib/view-bundler.js +25 -97
- package/vendor/cli/dist/config/define.d.ts +8 -0
- package/vendor/cli/dist/connectors/README.md +1 -1
- package/vendor/cli/dist/connectors/linkedin-inbox-adapter.js +4 -7
- package/vendor/cli/dist/connectors/linkedin.ts +53 -34
- package/vendor/cli/dist/connectors/reddit.ts +92 -20
- package/vendor/cli/dist/connectors/slack.ts +1 -0
- package/vendor/cli/dist/connectors/whatsapp-web-adapter.js +41 -11
- package/vendor/cli/dist/connectors/whatsapp-web-helpers.ts +1 -1
- package/vendor/cli/dist/connectors/whatsapp_web.ts +2 -2
- package/vendor/cli/dist/connectors/x-identity.ts +5 -3
- package/vendor/cli/dist/runtime-components.json +4 -4
- package/vendor/cli/dist/templates/AGENTS.md.tmpl +10 -3
- package/vendor/cli/package.json +1 -1
- package/vendor/connector-sdk/package.json +1 -1
- package/vendor/connector-worker/dist/agent-turn/gateway-tools.d.ts +2 -2
- package/vendor/connector-worker/dist/agent-turn/gateway-tools.js +2 -2
- package/vendor/connector-worker/dist/agent-turn/guest-entry.js +34 -2
- package/vendor/connector-worker/dist/agent-turn/guest.bundle.js +362 -300
- package/vendor/connector-worker/dist/agent-turn/native-session.d.ts +12 -0
- package/vendor/connector-worker/dist/agent-turn/native-session.js +32 -6
- package/vendor/connector-worker/dist/agent-turn/types.d.ts +24 -3
- package/vendor/connector-worker/dist/daemon/agent-turn.js +5 -1
- package/vendor/connector-worker/dist/daemon/automation.js +20 -15
- package/vendor/connector-worker/dist/isolate/prelude.js +93 -44
- package/vendor/connector-worker/package.json +1 -1
- package/vendor/core/dist/agent-policy.js +0 -3
- package/vendor/core/dist/agent-tooling.d.ts +1 -1
- package/vendor/core/dist/agent-tooling.js +3 -1
- package/vendor/core/dist/contracts/agent-settings.d.ts +6 -2
- package/vendor/core/dist/contracts/agent-settings.js +12 -1
- package/vendor/core/dist/contracts/tools/manage-views.d.ts +53 -234
- package/vendor/core/dist/contracts/tools/manage-views.js +50 -76
- package/vendor/core/dist/contracts/tools/view-attach.d.ts +5 -8
- package/vendor/core/dist/contracts/tools/view-attach.js +14 -31
- package/vendor/core/dist/contracts/tools/view-definition.d.ts +21 -0
- package/vendor/core/dist/contracts/tools/view-definition.js +165 -0
- package/vendor/core/dist/contracts/worker/protocol.d.ts +39 -2
- package/vendor/core/dist/contracts/worker/protocol.js +24 -1
- package/vendor/core/dist/index.d.ts +1 -1
- package/vendor/core/dist/index.js +2 -1
- package/vendor/core/dist/suggestions.d.ts +15 -2
- package/vendor/core/dist/suggestions.js +48 -3
- package/vendor/core/dist/types.d.ts +26 -0
- package/vendor/core/dist/types.js +5 -0
- package/vendor/core/package.json +11 -5
- package/vendor/postgres/cf/src/connection.js +18 -0
- package/vendor/postgres/cjs/src/connection.js +18 -0
- package/vendor/postgres/src/connection.js +18 -0
- /package/vendor/postgres/{.bun-tag-f39dafdb2305d504 → .bun-tag-2f292c6554a8475e} +0 -0
|
@@ -12,4 +12,16 @@ export declare function createNativeSession(input: AgentTurnInput, tools: AgentT
|
|
|
12
12
|
*/
|
|
13
13
|
export declare function promptNativeSession(session: AgentSession, text: string, images?: AgentTurnInput['images']): Promise<void>;
|
|
14
14
|
export declare function nativeSessionJsonl(session: AgentSession): string;
|
|
15
|
+
/**
|
|
16
|
+
* One side request on the session's own model, system prompt, tools and
|
|
17
|
+
* history, with `text` as a final user message. Nothing is appended to the
|
|
18
|
+
* session, so the question and its answer never reach the transcript; sending
|
|
19
|
+
* the same prefix the turn just sent is what lets the provider's prompt cache
|
|
20
|
+
* cover it. The side request does not inherit the session's thinking level.
|
|
21
|
+
* Resolves with the reply's text, '' when it has none.
|
|
22
|
+
*/
|
|
23
|
+
export declare function askAside(session: AgentSession, apiKey: string, text: string, options: {
|
|
24
|
+
maxTokens: number;
|
|
25
|
+
signal: AbortSignal;
|
|
26
|
+
}): Promise<string>;
|
|
15
27
|
//# sourceMappingURL=native-session.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Agent } from '@mariozechner/pi-agent-core';
|
|
2
|
-
import { registerApiProvider, streamSimple } from '@mariozechner/pi-ai';
|
|
2
|
+
import { completeSimple, registerApiProvider, streamSimple } from '@mariozechner/pi-ai';
|
|
3
3
|
import { streamAnthropic, streamSimpleAnthropic } from '@mariozechner/pi-ai/anthropic';
|
|
4
4
|
import { streamOpenAICompletions, streamSimpleOpenAICompletions } from '@mariozechner/pi-ai/openai-completions';
|
|
5
5
|
import { streamOpenAICodexResponses, streamSimpleOpenAICodexResponses } from '@mariozechner/pi-ai/openai-codex-responses';
|
|
@@ -7,6 +7,15 @@ import { streamOpenAIResponses, streamSimpleOpenAIResponses } from '@mariozechne
|
|
|
7
7
|
import { AgentSession, SessionManager, SettingsManager, convertToLlm, CURRENT_SESSION_VERSION } from '@mariozechner/pi-coding-agent';
|
|
8
8
|
import { createLobuResourceLoader } from '@lobu/plugin-toolkit/pi-resources';
|
|
9
9
|
import { SESSION_PATH, withSessionSnapshot } from './pi-session-fs.js';
|
|
10
|
+
/**
|
|
11
|
+
* Keep native custom/summary conversion. Pi stores an empty text block for
|
|
12
|
+
* image-only prompts; omit it only on the wire, where OpenAI rejects it.
|
|
13
|
+
*/
|
|
14
|
+
function toLlm(messages) {
|
|
15
|
+
return convertToLlm(messages).map((message) => message.role === 'user' && Array.isArray(message.content)
|
|
16
|
+
? { ...message, content: message.content.filter((part) => part.type !== 'text' || part.text.trim().length > 0) }
|
|
17
|
+
: message);
|
|
18
|
+
}
|
|
10
19
|
/** Pi owns session state and lifecycle; Lobu supplies only admitted host capabilities. */
|
|
11
20
|
export function createNativeSession(input, tools, getTransientContext) {
|
|
12
21
|
// Exhaustive over Pi's `ThinkingLevel`, so a level added or renamed upstream
|
|
@@ -55,6 +64,7 @@ export function createNativeSession(input, tools, getTransientContext) {
|
|
|
55
64
|
// For a model absent from the registry, an explicit effort is the user's
|
|
56
65
|
// request to try reasoning; known non-reasoning models are rejected above.
|
|
57
66
|
reasoning: input.provider.reasoning ?? (thinkingLevel !== 'off'),
|
|
67
|
+
...(input.provider.thinkingLevelMap ? { thinkingLevelMap: input.provider.thinkingLevelMap } : {}),
|
|
58
68
|
input: input.provider.input ?? ['text'],
|
|
59
69
|
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
60
70
|
contextWindow: input.compaction?.contextWindow ?? 200_000,
|
|
@@ -115,11 +125,7 @@ export function createNativeSession(input, tools, getTransientContext) {
|
|
|
115
125
|
let session;
|
|
116
126
|
const agent = new Agent({
|
|
117
127
|
initialState: { model, messages: context.messages, thinkingLevel },
|
|
118
|
-
|
|
119
|
-
// image-only prompts; omit it only on the wire, where OpenAI rejects it.
|
|
120
|
-
convertToLlm: (messages) => convertToLlm(messages).map((message) => message.role === 'user' && Array.isArray(message.content)
|
|
121
|
-
? { ...message, content: message.content.filter((part) => part.type !== 'text' || part.text.trim().length > 0) }
|
|
122
|
-
: message),
|
|
128
|
+
convertToLlm: toLlm,
|
|
123
129
|
transformContext: (messages) => session.extensionRunner.emitContext(messages),
|
|
124
130
|
streamFn: (selected, context, options) => streamSimple(selected, context, {
|
|
125
131
|
...settings.getProviderRetrySettings(), ...options, apiKey: input.provider.apiKey,
|
|
@@ -229,4 +235,24 @@ export function nativeSessionJsonl(session) {
|
|
|
229
235
|
return [session.sessionManager.getHeader(), ...session.sessionManager.getEntries()]
|
|
230
236
|
.map((entry) => JSON.stringify(entry)).join('\n') + '\n';
|
|
231
237
|
}
|
|
238
|
+
/**
|
|
239
|
+
* One side request on the session's own model, system prompt, tools and
|
|
240
|
+
* history, with `text` as a final user message. Nothing is appended to the
|
|
241
|
+
* session, so the question and its answer never reach the transcript; sending
|
|
242
|
+
* the same prefix the turn just sent is what lets the provider's prompt cache
|
|
243
|
+
* cover it. The side request does not inherit the session's thinking level.
|
|
244
|
+
* Resolves with the reply's text, '' when it has none.
|
|
245
|
+
*/
|
|
246
|
+
export async function askAside(session, apiKey, text, options) {
|
|
247
|
+
const { model, systemPrompt, tools, messages } = session.agent.state;
|
|
248
|
+
// Apply transient context before appending the ask: the extension attaches
|
|
249
|
+
// it to the latest real user message, preserving the answer request's prefix.
|
|
250
|
+
const contextMessages = await session.extensionRunner.emitContext(messages);
|
|
251
|
+
const reply = await completeSimple(model, {
|
|
252
|
+
systemPrompt,
|
|
253
|
+
tools,
|
|
254
|
+
messages: toLlm([...contextMessages, { role: 'user', content: [{ type: 'text', text }], timestamp: Date.now() }]),
|
|
255
|
+
}, { apiKey, maxTokens: options.maxTokens, signal: options.signal });
|
|
256
|
+
return reply.content.flatMap((block) => block.type === 'text' ? [block.text] : []).join('');
|
|
257
|
+
}
|
|
232
258
|
//# sourceMappingURL=native-session.js.map
|
|
@@ -45,6 +45,14 @@ export interface AgentTurnProvider {
|
|
|
45
45
|
* anything else gets `'off'`.
|
|
46
46
|
*/
|
|
47
47
|
reasoning?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* pi-ai's `Model.thinkingLevelMap` from its registry: the provider's name
|
|
50
|
+
* for each thinking level, `null` where the model does not serve it. pi-ai
|
|
51
|
+
* reads `off: null` as "send no effort", which is what a model that cannot
|
|
52
|
+
* turn reasoning off (gpt-5-mini) needs; without it pi-ai sends
|
|
53
|
+
* `effort: "none"` and the provider rejects the request.
|
|
54
|
+
*/
|
|
55
|
+
thinkingLevelMap?: Partial<Record<string, string | null>>;
|
|
48
56
|
/**
|
|
49
57
|
* The modalities the model accepts, in pi-ai's `Model.input` vocabulary. The
|
|
50
58
|
* gateway resolves it from pi-ai's registry; the guest only passes it
|
|
@@ -98,8 +106,8 @@ export interface AgentTurnTool {
|
|
|
98
106
|
/** The guest's own workspace tools, by name. */
|
|
99
107
|
export type AgentTurnBuiltinTool = 'bash' | 'read' | 'write' | 'edit' | 'grep' | 'ls' | 'find';
|
|
100
108
|
/**
|
|
101
|
-
* A gateway tool the turn may call — `ask_user`, `send_message
|
|
102
|
-
*
|
|
109
|
+
* A gateway tool the turn may call — `ask_user`, `send_message` and the
|
|
110
|
+
* rest of `@lobu/plugin-conversations`.
|
|
103
111
|
*
|
|
104
112
|
* The producer names them; the guest runs the plugin package's OWN
|
|
105
113
|
* implementation, bundled in. They are not reimplemented here and not proxied
|
|
@@ -108,7 +116,7 @@ export type AgentTurnBuiltinTool = 'bash' | 'read' | 'write' | 'edit' | 'grep' |
|
|
|
108
116
|
* so the turn still carries exactly one credential and reaches exactly one
|
|
109
117
|
* host.
|
|
110
118
|
*/
|
|
111
|
-
export type AgentTurnGatewayTool = 'list_conversations' | 'read_conversation' | 'send_message' | 'present_event' | 'schedule_followup' | 'react' | 'edit_message' | 'delete_message' | 'ask_user'
|
|
119
|
+
export type AgentTurnGatewayTool = 'list_conversations' | 'read_conversation' | 'send_message' | 'present_event' | 'schedule_followup' | 'react' | 'edit_message' | 'delete_message' | 'ask_user';
|
|
112
120
|
/**
|
|
113
121
|
* A media tool the turn may call — `@lobu/plugin-media`'s own.
|
|
114
122
|
*
|
|
@@ -155,6 +163,11 @@ export interface AgentTurnTools {
|
|
|
155
163
|
* whenever `gateway` or `media` is non-empty.
|
|
156
164
|
*/
|
|
157
165
|
conversation?: AgentTurnConversation;
|
|
166
|
+
/**
|
|
167
|
+
* After the answer, ask the same model for follow-up chips and return them
|
|
168
|
+
* with the turn result. Set only for a human-facing turn.
|
|
169
|
+
*/
|
|
170
|
+
followUps?: true;
|
|
158
171
|
}
|
|
159
172
|
/**
|
|
160
173
|
* What `@lobu/plugin-conversations` calls `GatewayParams` minus the two the
|
|
@@ -385,5 +398,13 @@ export interface AgentTurnOutput {
|
|
|
385
398
|
* suppression does the rest.
|
|
386
399
|
*/
|
|
387
400
|
repliedInBand?: boolean;
|
|
401
|
+
/**
|
|
402
|
+
* Follow-up chips the same model proposed for the owner's answer, already
|
|
403
|
+
* sanitized. Absent when the turn was not offered them or proposed none.
|
|
404
|
+
*/
|
|
405
|
+
suggestions?: Array<{
|
|
406
|
+
title: string;
|
|
407
|
+
message: string;
|
|
408
|
+
}>;
|
|
388
409
|
}
|
|
389
410
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -329,6 +329,7 @@ export async function executeAgentTurnRun(client, job, env, cfg) {
|
|
|
329
329
|
baseUrl: turn.provider.base_url,
|
|
330
330
|
...(turn.provider.max_tokens !== undefined ? { maxTokens: turn.provider.max_tokens } : {}),
|
|
331
331
|
...(turn.provider.reasoning !== undefined ? { reasoning: turn.provider.reasoning } : {}),
|
|
332
|
+
...(turn.provider.thinking_level_map ? { thinkingLevelMap: turn.provider.thinking_level_map } : {}),
|
|
332
333
|
// pi-ai's own `Model.input`, resolved by the gateway from pi-ai's
|
|
333
334
|
// model registry. Passed through untouched: pi is what enforces it.
|
|
334
335
|
...(turn.provider.input ? { input: turn.provider.input } : {}),
|
|
@@ -393,8 +394,10 @@ export async function executeAgentTurnRun(client, job, env, cfg) {
|
|
|
393
394
|
...(turn.tools.media && turn.tools.media.length > 0
|
|
394
395
|
? { media: turn.tools.media }
|
|
395
396
|
: {}),
|
|
397
|
+
...(turn.tools.follow_ups ? { followUps: true } : {}),
|
|
396
398
|
...((turn.tools.gateway && turn.tools.gateway.length > 0) ||
|
|
397
|
-
(turn.tools.media && turn.tools.media.length > 0)
|
|
399
|
+
(turn.tools.media && turn.tools.media.length > 0) ||
|
|
400
|
+
turn.tools.follow_ups
|
|
398
401
|
? {
|
|
399
402
|
conversation: {
|
|
400
403
|
channelId: turn.tools.conversation.channel_id,
|
|
@@ -573,6 +576,7 @@ export async function executeAgentTurnRun(client, job, env, cfg) {
|
|
|
573
576
|
...(input.firstError ? { first_error: input.firstError } : {}),
|
|
574
577
|
})),
|
|
575
578
|
...(result.turn.repliedInBand ? { replied_in_band: true } : {}),
|
|
579
|
+
...(result.turn.suggestions ? { suggestions: result.turn.suggestions } : {}),
|
|
576
580
|
exit_reason: 'ok',
|
|
577
581
|
});
|
|
578
582
|
if (receipt.status !== 'completed')
|
|
@@ -48,20 +48,23 @@ function monitorDeviceAgentRun(client, runId, cfg, label) {
|
|
|
48
48
|
cfg.shutdownSignal?.addEventListener('abort', onShutdown, { once: true });
|
|
49
49
|
if (cfg.shutdownSignal?.aborted)
|
|
50
50
|
onShutdown();
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
51
|
+
// Beat once at start: the server's fast stale reaper only covers a run that
|
|
52
|
+
// has beaten since its claim, and a CLI that exits before the first interval
|
|
53
|
+
// would otherwise wait out the coarse TTL if its exit report is lost.
|
|
54
|
+
const beat = () => client.heartbeat(runId).catch((error) => {
|
|
55
|
+
if (error instanceof WorkerHttpError && error.status === 409) {
|
|
56
|
+
if (!abortController.signal.aborted) {
|
|
57
|
+
log.info(`[executor] ${label} run ${runId} is no longer active; stopping the local CLI`);
|
|
58
|
+
terminalController.abort();
|
|
59
|
+
abortController.abort();
|
|
60
|
+
clearInterval(heartbeat);
|
|
61
61
|
}
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
log.debug(`[executor] ${label} heartbeat failed:`, error);
|
|
65
|
+
});
|
|
66
|
+
const heartbeat = setInterval(beat, cfg.heartbeatIntervalMs ?? 30_000);
|
|
67
|
+
void beat();
|
|
65
68
|
return {
|
|
66
69
|
abortController,
|
|
67
70
|
terminalSignal: terminalController.signal,
|
|
@@ -90,7 +93,9 @@ export const DEFAULT_DEVICE_AGENT_TIMEOUT_MS = 600_000;
|
|
|
90
93
|
/** Cap on the CLI-output tail folded into `runs.error_message`. */
|
|
91
94
|
const DETAIL_TAIL_CHARS = 500;
|
|
92
95
|
const LOCAL_MAX_ROUNDS = 8;
|
|
93
|
-
|
|
96
|
+
/** Backoff doubles from 2s, so retries span ~1 min, outlasting a heartbeat
|
|
97
|
+
* interval and a brief gateway outage. */
|
|
98
|
+
const EXIT_REPORT_DELIVERY_ATTEMPTS = 6;
|
|
94
99
|
const EXIT_REPORT_RETRY_DELAY_MS = 2000;
|
|
95
100
|
const TRANSCRIPT_DELIVERY_ATTEMPTS = 3;
|
|
96
101
|
const TRANSCRIPT_RETRY_DELAY_MS = 250;
|
|
@@ -865,7 +870,7 @@ export async function deliverExitReport(client, runId, result, finalizeAttempt)
|
|
|
865
870
|
if (!retriable)
|
|
866
871
|
return null;
|
|
867
872
|
if (attempt + 1 < EXIT_REPORT_DELIVERY_ATTEMPTS) {
|
|
868
|
-
await sleep(EXIT_REPORT_RETRY_DELAY_MS *
|
|
873
|
+
await sleep(EXIT_REPORT_RETRY_DELAY_MS * 2 ** attempt);
|
|
869
874
|
}
|
|
870
875
|
}
|
|
871
876
|
}
|
|
@@ -1337,6 +1337,7 @@ var exports = module.exports;
|
|
|
1337
1337
|
});
|
|
1338
1338
|
Response.prototype._consume = function () {
|
|
1339
1339
|
if (this.bodyUsed) return Promise.reject(new TypeError('Body is unusable: Body has already been read'));
|
|
1340
|
+
if (this._stream && this._stream.locked) return Promise.reject(new TypeError('Body is unusable: Body is locked'));
|
|
1340
1341
|
this._bodyUsed = true;
|
|
1341
1342
|
if (this._stream) return readAllBytes(this._stream);
|
|
1342
1343
|
return Promise.resolve(this._bytes || new Uint8Array(0));
|
|
@@ -1355,6 +1356,7 @@ var exports = module.exports;
|
|
|
1355
1356
|
};
|
|
1356
1357
|
Response.prototype.clone = function () {
|
|
1357
1358
|
if (this.bodyUsed) throw new TypeError('Response.clone: Body has already been consumed.');
|
|
1359
|
+
if (this._stream && this._stream.locked) throw new TypeError('Response.clone: Body is locked.');
|
|
1358
1360
|
// Cloning a streamed body means teeing it, which nothing on this lane
|
|
1359
1361
|
// does; a guest-constructed body still has its bytes to copy.
|
|
1360
1362
|
if (this._bytes === null && this._stream !== null) throw new TypeError('Response.clone: a streamed body cannot be cloned on the isolate lane');
|
|
@@ -1921,26 +1923,31 @@ var exports = module.exports;
|
|
|
1921
1923
|
// ---------------------------------------------------------------------------
|
|
1922
1924
|
function ReadableStream(underlyingSource) {
|
|
1923
1925
|
this._source = underlyingSource || {};
|
|
1924
|
-
// Set by the first read; Response.bodyUsed reports it.
|
|
1926
|
+
// Set by the first read or a cancel; Response.bodyUsed reports it.
|
|
1925
1927
|
this._disturbed = false;
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
+
this._locked = false;
|
|
1929
|
+
// Source state outlives a reader's lock, including buffered chunks and
|
|
1930
|
+
// terminal outcomes. Reacquiring a reader must not restart the source.
|
|
1928
1931
|
var self = this;
|
|
1929
1932
|
var queue = [];
|
|
1930
1933
|
var waiters = [];
|
|
1931
1934
|
var isClosed = false;
|
|
1935
|
+
var isErrored = false;
|
|
1932
1936
|
var streamError = null;
|
|
1933
1937
|
|
|
1934
1938
|
function settleWaiters(result) {
|
|
1935
|
-
while (waiters.length > 0) waiters.shift()(result);
|
|
1939
|
+
while (waiters.length > 0) waiters.shift().resolve(result);
|
|
1940
|
+
}
|
|
1941
|
+
function rejectWaiters(err) {
|
|
1942
|
+
while (waiters.length > 0) waiters.shift().reject(err);
|
|
1936
1943
|
}
|
|
1937
1944
|
|
|
1938
1945
|
var controller = {
|
|
1939
1946
|
enqueue: function (chunk) {
|
|
1940
|
-
// A chunk the source still delivers after a close
|
|
1941
|
-
// dropped: every read from that point on already
|
|
1942
|
-
if (isClosed) return;
|
|
1943
|
-
if (waiters.length > 0) waiters.shift()({ value: chunk, done: false });
|
|
1947
|
+
// A chunk the source still delivers after a close, a cancel or an
|
|
1948
|
+
// error is dropped: every read from that point on already settled.
|
|
1949
|
+
if (isClosed || isErrored) return;
|
|
1950
|
+
if (waiters.length > 0) waiters.shift().resolve({ value: chunk, done: false });
|
|
1944
1951
|
else queue.push(chunk);
|
|
1945
1952
|
},
|
|
1946
1953
|
close: function () {
|
|
@@ -1952,54 +1959,96 @@ var exports = module.exports;
|
|
|
1952
1959
|
// is dropped, so a read from then on still reports done. The fetch
|
|
1953
1960
|
// body reaches this when a cancel kills its in-flight pull, which
|
|
1954
1961
|
// answers with an AbortError only after the cancel has ended the stream.
|
|
1955
|
-
if (isClosed) return;
|
|
1962
|
+
if (isClosed || isErrored) return;
|
|
1963
|
+
isErrored = true;
|
|
1956
1964
|
streamError = err;
|
|
1957
|
-
|
|
1965
|
+
queue.length = 0;
|
|
1966
|
+
rejectWaiters(err);
|
|
1958
1967
|
}
|
|
1959
1968
|
};
|
|
1960
1969
|
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1970
|
+
this._read = function () {
|
|
1971
|
+
self._disturbed = true;
|
|
1972
|
+
if (isErrored) return Promise.reject(streamError);
|
|
1973
|
+
if (queue.length > 0) {
|
|
1974
|
+
return Promise.resolve({ value: queue.shift(), done: false });
|
|
1975
|
+
}
|
|
1976
|
+
if (isClosed) {
|
|
1977
|
+
return Promise.resolve({ value: undefined, done: true });
|
|
1978
|
+
}
|
|
1979
|
+
// The waiter is registered BEFORE pull(), because a source that
|
|
1980
|
+
// enqueues synchronously would otherwise push into the queue while no
|
|
1981
|
+
// waiter was registered and leave this read hanging forever. Reads
|
|
1982
|
+
// queue in order: each pull answers the oldest waiter.
|
|
1983
|
+
var waiter = new Promise(function (resolve, reject) {
|
|
1984
|
+
waiters.push({ resolve: resolve, reject: reject });
|
|
1985
|
+
});
|
|
1986
|
+
if (self._source.pull) {
|
|
1987
|
+
try {
|
|
1988
|
+
Promise.resolve(self._source.pull(controller)).catch(controller.error);
|
|
1989
|
+
} catch (err) {
|
|
1990
|
+
controller.error(err);
|
|
1991
|
+
}
|
|
1992
|
+
}
|
|
1993
|
+
return waiter;
|
|
1994
|
+
};
|
|
1995
|
+
this._release = function () {
|
|
1996
|
+
rejectWaiters(new TypeError('ReadableStream reader has been released'));
|
|
1997
|
+
};
|
|
1998
|
+
// Cancelling ends the stream: the queue is dropped and every read from
|
|
1999
|
+
// here on reports done. Without that a later read would pull the source
|
|
2000
|
+
// again -- for a fetch body or a socket, a read on what the cancel just
|
|
2001
|
+
// released. A reader and the stream itself both cancel through here.
|
|
2002
|
+
this._cancel = function (reason) {
|
|
2003
|
+
self._disturbed = true;
|
|
2004
|
+
if (isErrored) return Promise.reject(streamError);
|
|
2005
|
+
if (isClosed && queue.length === 0) return Promise.resolve();
|
|
2006
|
+
isClosed = true;
|
|
2007
|
+
queue.length = 0;
|
|
2008
|
+
settleWaiters({ value: undefined, done: true });
|
|
2009
|
+
try {
|
|
2010
|
+
return Promise.resolve(self._source.cancel ? self._source.cancel(reason) : undefined).then(function () {});
|
|
2011
|
+
} catch (err) {
|
|
2012
|
+
return Promise.reject(err);
|
|
2013
|
+
}
|
|
2014
|
+
};
|
|
1964
2015
|
|
|
2016
|
+
if (this._source.start) {
|
|
2017
|
+
Promise.resolve(this._source.start(controller)).catch(controller.error);
|
|
2018
|
+
}
|
|
2019
|
+
}
|
|
2020
|
+
Object.defineProperty(ReadableStream.prototype, 'locked', {
|
|
2021
|
+
get: function () { return this._locked; },
|
|
2022
|
+
enumerable: true
|
|
2023
|
+
});
|
|
2024
|
+
ReadableStream.prototype.getReader = function () {
|
|
2025
|
+
if (this._locked) throw new TypeError('ReadableStream is locked to a reader');
|
|
2026
|
+
this._locked = true;
|
|
2027
|
+
var self = this;
|
|
2028
|
+
var released = false;
|
|
1965
2029
|
return {
|
|
1966
2030
|
read: function () {
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
// The waiter is registered BEFORE pull(), because a source that
|
|
1976
|
-
// enqueues synchronously would otherwise push into the queue while no
|
|
1977
|
-
// waiter was registered and leave this read hanging forever. Reads
|
|
1978
|
-
// queue in order: each pull answers the oldest waiter.
|
|
1979
|
-
var waiter = new Promise(function (resolve) {
|
|
1980
|
-
waiters.push(resolve);
|
|
1981
|
-
});
|
|
1982
|
-
if (self._source && self._source.pull) {
|
|
1983
|
-
self._source.pull(controller);
|
|
1984
|
-
}
|
|
1985
|
-
return waiter;
|
|
2031
|
+
if (released) return Promise.reject(new TypeError('ReadableStream reader has been released'));
|
|
2032
|
+
return self._read();
|
|
2033
|
+
},
|
|
2034
|
+
releaseLock: function () {
|
|
2035
|
+
if (released) return;
|
|
2036
|
+
released = true;
|
|
2037
|
+
self._locked = false;
|
|
2038
|
+
self._release();
|
|
1986
2039
|
},
|
|
1987
|
-
releaseLock: function () {},
|
|
1988
|
-
// Cancelling ends the stream: the queue is dropped and every read from
|
|
1989
|
-
// here on reports done. Without that a later read would pull the source
|
|
1990
|
-
// again -- for a fetch body or a socket, a read on what the cancel just
|
|
1991
|
-
// released.
|
|
1992
2040
|
cancel: function (reason) {
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
settleWaiters({ value: undefined, done: true });
|
|
1996
|
-
if (self._source && self._source.cancel) {
|
|
1997
|
-
return Promise.resolve(self._source.cancel(reason));
|
|
1998
|
-
}
|
|
1999
|
-
return Promise.resolve();
|
|
2041
|
+
if (released) return Promise.reject(new TypeError('ReadableStream reader has been released'));
|
|
2042
|
+
return self._cancel(reason);
|
|
2000
2043
|
}
|
|
2001
2044
|
};
|
|
2002
2045
|
};
|
|
2046
|
+
// "await res.body.cancel()" drops a body nobody will read, a retried 503
|
|
2047
|
+
// for one; refused while a reader holds the lock, as on every runtime.
|
|
2048
|
+
ReadableStream.prototype.cancel = function (reason) {
|
|
2049
|
+
if (this._locked) return Promise.reject(new TypeError('Cannot cancel a ReadableStream that is locked to a reader'));
|
|
2050
|
+
return this._cancel(reason);
|
|
2051
|
+
};
|
|
2003
2052
|
global.ReadableStream = ReadableStream;
|
|
2004
2053
|
|
|
2005
2054
|
function WritableStream(underlyingSink) {
|
|
@@ -42,9 +42,6 @@ exports.CUSTOM_TOOL_METADATA = {
|
|
|
42
42
|
delete_message: {
|
|
43
43
|
description: "Delete a message the bot itself sent, addressed by a conversation or thread handle + message id. Only the bot's own messages can be deleted.",
|
|
44
44
|
},
|
|
45
|
-
suggest_actions: {
|
|
46
|
-
description: 'Offer optional follow-up actions as tappable chips when the user asks for suggested next steps, or when a concrete choice would help them proceed. Default to a plain text reply: skip routine answers, acknowledgements, corrections, status updates, and requests you already completed, and respect an explicit ask for no suggestions or a closed topic. Do not invent extra work, repeat actions already offered, or defer work you should do now. One useful action is enough and 4 is the ceiling — never pad the list. Call at most once per turn. Each `message` is sent verbatim as the user\'s next turn, so write it in the user\'s voice ("Show me the diff", not "I can show you the diff"). This posts immediately, independently of the final reply, so each suggestion must make sense on its own. Non-blocking; finish your reply normally.',
|
|
47
|
-
},
|
|
48
45
|
};
|
|
49
46
|
/** Every always-on rule, narrowed per turn by `renderAlwaysOnToolPolicyRulesFor`. */
|
|
50
47
|
exports.TOOL_RULES = [
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* compile error to say so — `assertIsolateEligible` catches it at run time.
|
|
15
15
|
*/
|
|
16
16
|
export { CUSTOM_TOOL_METADATA, type CustomToolMetadata, getCustomToolDescription, renderAlwaysOnToolPolicyRulesFor, } from "./agent-policy";
|
|
17
|
-
export { sanitizeSuggestionPrompts, SUGGESTION_LIMITS, type SuggestedPrompt, } from "./suggestions";
|
|
17
|
+
export { FOLLOW_UP_SUGGESTIONS_PROMPT, parseFollowUpSuggestions, sanitizeSuggestionPrompts, SUGGESTION_LIMITS, type SuggestedPrompt, } from "./suggestions";
|
|
18
18
|
/**
|
|
19
19
|
* What a tool logs, without saying how. The worker lane passes core's winston
|
|
20
20
|
* logger; the isolate guest passes its own console-backed one. Structurally
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* compile error to say so — `assertIsolateEligible` catches it at run time.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.SUGGESTION_LIMITS = exports.sanitizeSuggestionPrompts = exports.renderAlwaysOnToolPolicyRulesFor = exports.getCustomToolDescription = exports.CUSTOM_TOOL_METADATA = void 0;
|
|
18
|
+
exports.SUGGESTION_LIMITS = exports.sanitizeSuggestionPrompts = exports.parseFollowUpSuggestions = exports.FOLLOW_UP_SUGGESTIONS_PROMPT = exports.renderAlwaysOnToolPolicyRulesFor = exports.getCustomToolDescription = exports.CUSTOM_TOOL_METADATA = void 0;
|
|
19
19
|
exports.withLobuFileParameters = withLobuFileParameters;
|
|
20
20
|
const typebox_1 = require("@sinclair/typebox");
|
|
21
21
|
var agent_policy_1 = require("./agent-policy");
|
|
@@ -23,6 +23,8 @@ Object.defineProperty(exports, "CUSTOM_TOOL_METADATA", { enumerable: true, get:
|
|
|
23
23
|
Object.defineProperty(exports, "getCustomToolDescription", { enumerable: true, get: function () { return agent_policy_1.getCustomToolDescription; } });
|
|
24
24
|
Object.defineProperty(exports, "renderAlwaysOnToolPolicyRulesFor", { enumerable: true, get: function () { return agent_policy_1.renderAlwaysOnToolPolicyRulesFor; } });
|
|
25
25
|
var suggestions_1 = require("./suggestions");
|
|
26
|
+
Object.defineProperty(exports, "FOLLOW_UP_SUGGESTIONS_PROMPT", { enumerable: true, get: function () { return suggestions_1.FOLLOW_UP_SUGGESTIONS_PROMPT; } });
|
|
27
|
+
Object.defineProperty(exports, "parseFollowUpSuggestions", { enumerable: true, get: function () { return suggestions_1.parseFollowUpSuggestions; } });
|
|
26
28
|
Object.defineProperty(exports, "sanitizeSuggestionPrompts", { enumerable: true, get: function () { return suggestions_1.sanitizeSuggestionPrompts; } });
|
|
27
29
|
Object.defineProperty(exports, "SUGGESTION_LIMITS", { enumerable: true, get: function () { return suggestions_1.SUGGESTION_LIMITS; } });
|
|
28
30
|
const fileToolSchemas = {
|
|
@@ -66,7 +66,7 @@ export declare const AgentInlineGuardrailSchema: import("@sinclair/typebox").TOb
|
|
|
66
66
|
/**
|
|
67
67
|
* For `judge` pre-tool: optional tool-name filter (run only for these tools).
|
|
68
68
|
* For `require-tool`: the tool name(s) that must appear in this turn's
|
|
69
|
-
* `toolsUsed` (manual, e.g. `["
|
|
69
|
+
* `toolsUsed` (manual, e.g. `["send_message"]`).
|
|
70
70
|
*/
|
|
71
71
|
tools: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
|
|
72
72
|
domains: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
|
|
@@ -149,7 +149,7 @@ export declare const AgentSettingsStoredSchema: import("@sinclair/typebox").TObj
|
|
|
149
149
|
/**
|
|
150
150
|
* For `judge` pre-tool: optional tool-name filter (run only for these tools).
|
|
151
151
|
* For `require-tool`: the tool name(s) that must appear in this turn's
|
|
152
|
-
* `toolsUsed` (manual, e.g. `["
|
|
152
|
+
* `toolsUsed` (manual, e.g. `["send_message"]`).
|
|
153
153
|
*/
|
|
154
154
|
tools: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
|
|
155
155
|
domains: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
|
|
@@ -157,6 +157,10 @@ export declare const AgentSettingsStoredSchema: import("@sinclair/typebox").TObj
|
|
|
157
157
|
sandboxId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
158
158
|
verboseLogging: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
159
159
|
showToolCalls: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
160
|
+
starters: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
161
|
+
title: import("@sinclair/typebox").TString;
|
|
162
|
+
message: import("@sinclair/typebox").TString;
|
|
163
|
+
}>>>;
|
|
160
164
|
updatedAt: import("@sinclair/typebox").TNumber;
|
|
161
165
|
}>;
|
|
162
166
|
export type AgentSettingsStored = Static<typeof AgentSettingsStoredSchema>;
|
|
@@ -76,7 +76,7 @@ exports.AgentInlineGuardrailSchema = typebox_1.Type.Object({
|
|
|
76
76
|
/**
|
|
77
77
|
* For `judge` pre-tool: optional tool-name filter (run only for these tools).
|
|
78
78
|
* For `require-tool`: the tool name(s) that must appear in this turn's
|
|
79
|
-
* `toolsUsed` (manual, e.g. `["
|
|
79
|
+
* `toolsUsed` (manual, e.g. `["send_message"]`).
|
|
80
80
|
*/
|
|
81
81
|
tools: typebox_1.Type.Optional(typebox_1.Type.Array(typebox_1.Type.String())),
|
|
82
82
|
domains: typebox_1.Type.Optional(typebox_1.Type.Array(typebox_1.Type.String())),
|
|
@@ -106,6 +106,16 @@ exports.SkillConfigSchema = typebox_1.Type.Object({
|
|
|
106
106
|
exports.SkillsConfigSchema = typebox_1.Type.Object({
|
|
107
107
|
skills: typebox_1.Type.Array(exports.SkillConfigSchema),
|
|
108
108
|
});
|
|
109
|
+
/**
|
|
110
|
+
* Conversation starters an agent offers on an empty chat (web) and as Slack
|
|
111
|
+
* assistant thread-start prompts. Same `{title,message}` shape as follow-up
|
|
112
|
+
* chips; three at most so the empty state stays a short, tappable row.
|
|
113
|
+
*/
|
|
114
|
+
const AGENT_STARTERS_MAX = 3;
|
|
115
|
+
const AgentStarterSchema = typebox_1.Type.Object({
|
|
116
|
+
title: typebox_1.Type.String({ minLength: 1, maxLength: 72 }),
|
|
117
|
+
message: typebox_1.Type.String({ minLength: 1, maxLength: 2000 }),
|
|
118
|
+
});
|
|
109
119
|
// ── AgentSettingsStored ─────────────────────────────────────────────────────
|
|
110
120
|
/**
|
|
111
121
|
* What the DB persists (the `agents` row's settings jsonb columns). EXCLUDES
|
|
@@ -130,6 +140,7 @@ exports.AgentSettingsStoredSchema = typebox_1.Type.Object({
|
|
|
130
140
|
sandboxId: typebox_1.Type.Optional(typebox_1.Type.String()),
|
|
131
141
|
verboseLogging: typebox_1.Type.Optional(typebox_1.Type.Boolean()),
|
|
132
142
|
showToolCalls: typebox_1.Type.Optional(typebox_1.Type.Boolean()),
|
|
143
|
+
starters: typebox_1.Type.Optional(typebox_1.Type.Array(AgentStarterSchema, { maxItems: AGENT_STARTERS_MAX })),
|
|
133
144
|
updatedAt: typebox_1.Type.Number(),
|
|
134
145
|
});
|
|
135
146
|
//# sourceMappingURL=agent-settings.js.map
|