@layernorm/overlay-agent-bridge-protocol 0.10.0 → 0.11.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/README.md +1 -1
- package/dist/command-output-text.d.ts +20 -0
- package/dist/command-output-text.d.ts.map +1 -0
- package/dist/command-output-text.js +43 -0
- package/dist/command-output-text.js.map +1 -0
- package/dist/command-output.d.ts +18 -0
- package/dist/command-output.d.ts.map +1 -0
- package/dist/command-output.js +19 -0
- package/dist/command-output.js.map +1 -0
- package/dist/computer-tools.d.ts +534 -4
- package/dist/computer-tools.d.ts.map +1 -1
- package/dist/computer-tools.js +199 -3
- package/dist/computer-tools.js.map +1 -1
- package/dist/index.d.ts +20 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/local-tools.d.ts +39 -20
- package/dist/local-tools.d.ts.map +1 -1
- package/dist/local-tools.js +8 -1
- package/dist/local-tools.js.map +1 -1
- package/dist/project-instructions.d.ts +17 -0
- package/dist/project-instructions.d.ts.map +1 -0
- package/dist/project-instructions.js +110 -0
- package/dist/project-instructions.js.map +1 -0
- package/dist/run-plan.d.ts +11 -0
- package/dist/run-plan.d.ts.map +1 -0
- package/dist/run-plan.js +23 -0
- package/dist/run-plan.js.map +1 -0
- package/dist/run-question-tool.d.ts +18 -0
- package/dist/run-question-tool.d.ts.map +1 -0
- package/dist/run-question-tool.js +17 -0
- package/dist/run-question-tool.js.map +1 -0
- package/dist/run-questions.d.ts +33 -0
- package/dist/run-questions.d.ts.map +1 -0
- package/dist/run-questions.js +79 -0
- package/dist/run-questions.js.map +1 -0
- package/dist/run-wait.d.ts +56 -0
- package/dist/run-wait.d.ts.map +1 -0
- package/dist/run-wait.js +66 -0
- package/dist/run-wait.js.map +1 -0
- package/package.json +16 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Questions an agent asks the person during a run. They travel as JSON inside
|
|
3
|
+
* the run's existing `question` string, so every stored wait and message part
|
|
4
|
+
* carries them unchanged. A plain string is a single free-text question.
|
|
5
|
+
*/
|
|
6
|
+
export type RunQuestionChoice = {
|
|
7
|
+
label: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
};
|
|
10
|
+
export type RunQuestion = {
|
|
11
|
+
prompt: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
choices?: RunQuestionChoice[];
|
|
14
|
+
multiple?: boolean;
|
|
15
|
+
allowCustomAnswer?: boolean;
|
|
16
|
+
optional?: boolean;
|
|
17
|
+
};
|
|
18
|
+
export declare function encodeRunQuestions(questions: readonly RunQuestion[]): string;
|
|
19
|
+
export declare function decodeRunQuestions(question: string): RunQuestion[];
|
|
20
|
+
/** Why these questions can't be shown to a person, or null when they can. */
|
|
21
|
+
export declare function runQuestionIssue(questions: readonly RunQuestion[]): string | null;
|
|
22
|
+
/** One question replies with just the answer; several pair each with its question. */
|
|
23
|
+
export declare function formatRunAnswers(questions: readonly RunQuestion[], answers: ReadonlyArray<readonly string[] | undefined>): string;
|
|
24
|
+
/** Questions and answers travel as plain text; these limits are the same for cloud runs and private threads. */
|
|
25
|
+
export declare const MAX_RUN_QUESTIONS_LENGTH = 2000;
|
|
26
|
+
export declare const MAX_RUN_ANSWER_LENGTH = 32000;
|
|
27
|
+
/** Why a set of questions can't be asked, or null when it can. */
|
|
28
|
+
export declare function runQuestionsIssue(questions: readonly RunQuestion[]): string | null;
|
|
29
|
+
/** The answer to a question tool call in a private thread: one object with the text `formatRunAnswers` wrote. */
|
|
30
|
+
export declare function readRunAnswer(output: unknown): {
|
|
31
|
+
answer: string;
|
|
32
|
+
} | null;
|
|
33
|
+
//# sourceMappingURL=run-questions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-questions.d.ts","sourceRoot":"","sources":["../src/run-questions.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KA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odeRunQuestions(questions) {
|
|
4
|
+
return JSON.stringify({ overlayRunQuestions: 1, questions });
|
|
5
|
+
}
|
|
6
|
+
function readChoice(value) {
|
|
7
|
+
if (!value || typeof value !== 'object')
|
|
8
|
+
return null;
|
|
9
|
+
const { label, description } = value;
|
|
10
|
+
if (typeof label !== 'string' || !label.trim())
|
|
11
|
+
return null;
|
|
12
|
+
return { label, ...(typeof description === 'string' && description ? { description } : {}) };
|
|
13
|
+
}
|
|
14
|
+
function readQuestion(value) {
|
|
15
|
+
if (!value || typeof value !== 'object')
|
|
16
|
+
return null;
|
|
17
|
+
const { prompt, description, choices, multiple, allowCustomAnswer, optional } = value;
|
|
18
|
+
if (typeof prompt !== 'string' || !prompt.trim())
|
|
19
|
+
return null;
|
|
20
|
+
const readChoices = Array.isArray(choices) ? choices.map(readChoice).filter(choice => choice !== null) : [];
|
|
21
|
+
return {
|
|
22
|
+
prompt,
|
|
23
|
+
...(typeof description === 'string' && description ? { description } : {}),
|
|
24
|
+
...(readChoices.length ? { choices: readChoices } : {}),
|
|
25
|
+
...(multiple === true ? { multiple } : {}),
|
|
26
|
+
...(allowCustomAnswer === true ? { allowCustomAnswer } : {}),
|
|
27
|
+
...(optional === true ? { optional } : {}),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export function decodeRunQuestions(question) {
|
|
31
|
+
try {
|
|
32
|
+
const parsed = JSON.parse(question);
|
|
33
|
+
if (parsed?.overlayRunQuestions === 1 && Array.isArray(parsed.questions)) {
|
|
34
|
+
const questions = parsed.questions.map(readQuestion).filter(item => item !== null);
|
|
35
|
+
if (questions.length)
|
|
36
|
+
return questions;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
// Not encoded, so it's a plain question.
|
|
41
|
+
}
|
|
42
|
+
return [{ prompt: question }];
|
|
43
|
+
}
|
|
44
|
+
/** Why these questions can't be shown to a person, or null when they can. */
|
|
45
|
+
export function runQuestionIssue(questions) {
|
|
46
|
+
for (const { prompt } of questions) {
|
|
47
|
+
const text = prompt.trim();
|
|
48
|
+
if (text.length < MIN_PROMPT_LENGTH || PLACEHOLDER_PROMPT.test(text)) {
|
|
49
|
+
return `"${text}" is not a real question. Ask the person something specific they can answer, or continue without asking.`;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
/** One question replies with just the answer; several pair each with its question. */
|
|
55
|
+
export function formatRunAnswers(questions, answers) {
|
|
56
|
+
if (questions.length === 1)
|
|
57
|
+
return (answers[0] ?? []).join(', ') || (questions[0]?.optional ? '(skipped)' : '');
|
|
58
|
+
return questions.map((question, index) => `${question.prompt}\n${answers[index]?.join(', ') || '(skipped)'}`).join('\n\n');
|
|
59
|
+
}
|
|
60
|
+
/** Questions and answers travel as plain text; these limits are the same for cloud runs and private threads. */
|
|
61
|
+
export const MAX_RUN_QUESTIONS_LENGTH = 2_000;
|
|
62
|
+
export const MAX_RUN_ANSWER_LENGTH = 32_000;
|
|
63
|
+
/** Why a set of questions can't be asked, or null when it can. */
|
|
64
|
+
export function runQuestionsIssue(questions) {
|
|
65
|
+
return runQuestionIssue(questions)
|
|
66
|
+
?? (encodeRunQuestions(questions).length > MAX_RUN_QUESTIONS_LENGTH ? 'These questions are too long. Shorten them or ask fewer.' : null);
|
|
67
|
+
}
|
|
68
|
+
/** The answer to a question tool call in a private thread: one object with the text `formatRunAnswers` wrote. */
|
|
69
|
+
export function readRunAnswer(output) {
|
|
70
|
+
if (!output || typeof output !== 'object' || Array.isArray(output))
|
|
71
|
+
return null;
|
|
72
|
+
const keys = Object.keys(output);
|
|
73
|
+
const { answer } = output;
|
|
74
|
+
if (keys.length !== 1 || typeof answer !== 'string')
|
|
75
|
+
return null;
|
|
76
|
+
const text = answer.trim();
|
|
77
|
+
return text && text.length <= MAX_RUN_ANSWER_LENGTH ? { answer: text } : null;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=run-questions.js.map
|
|
@@ -0,0 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C,IAAI,CAAC,CAAA;AAC5I,CAAC;AAED,iHAAiH;AACjH,MAAM,UAAU,aAAa,CAAC,MAAe;IAC3C,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;QAAE,OAAO,IAAI,CAAA;IAC/E,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAChC,MAAM,EAAE,MAAM,EAAE,GAAG,MAA8B,CAAA;IACjD,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,MAAM,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAA;IAChE,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,EAAE,CAAA;IAC1B,OAAO,IAAI,IAAI,IAAI,CAAC,MAAM,IAAI,qBAAqB,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAA;AAC/E,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { z } from 'zod/v3';
|
|
2
|
+
/** One way for agents to wait without using model calls, shared by the cloud harness and private threads. */
|
|
3
|
+
export declare const RUN_WAIT_TOOL = "harness_wait";
|
|
4
|
+
export declare const RUN_WAIT_MAX_SECONDS: number;
|
|
5
|
+
/** Access is checked again, and Stop is noticed, at least this often. */
|
|
6
|
+
export declare const RUN_WAIT_CHECK_MAX_MS = 60000;
|
|
7
|
+
export declare const RUN_WAIT_DESCRIPTION: string;
|
|
8
|
+
export declare const runWaitFields: {
|
|
9
|
+
seconds: z.ZodNumber;
|
|
10
|
+
terminalId: z.ZodOptional<z.ZodString>;
|
|
11
|
+
};
|
|
12
|
+
export type RunJobStatus = {
|
|
13
|
+
state: 'running';
|
|
14
|
+
} | {
|
|
15
|
+
state: 'ended';
|
|
16
|
+
exitCode: number | null;
|
|
17
|
+
}
|
|
18
|
+
/** The computer is off, so the job is gone. It is never started just to check. */
|
|
19
|
+
| {
|
|
20
|
+
state: 'computer_stopped';
|
|
21
|
+
}
|
|
22
|
+
/** The job can't be found, or this kind of check was refused: waiting longer can't help. */
|
|
23
|
+
| {
|
|
24
|
+
state: 'not_found';
|
|
25
|
+
message: string;
|
|
26
|
+
}
|
|
27
|
+
/** Could not be checked just now, for example because a Mac is asleep. */
|
|
28
|
+
| {
|
|
29
|
+
state: 'unavailable';
|
|
30
|
+
message: string;
|
|
31
|
+
};
|
|
32
|
+
export type RunWaitResult = {
|
|
33
|
+
status: 'time_passed' | 'job_ended' | 'computer_stopped' | 'job_not_found' | 'stopped';
|
|
34
|
+
waitedSeconds: number;
|
|
35
|
+
exitCode?: number | null;
|
|
36
|
+
jobRunning?: boolean;
|
|
37
|
+
message?: string;
|
|
38
|
+
};
|
|
39
|
+
/** Quick checks at first, so short jobs return soon, then up to one a minute. */
|
|
40
|
+
export declare function runWaitDelay(check: number, remainingMs: number): number;
|
|
41
|
+
/**
|
|
42
|
+
* The wait itself. `pause` is a durable sleep in the cloud and a timer on a person's computer; `keepGoing` renews the
|
|
43
|
+
* run and returns false once it was stopped.
|
|
44
|
+
*/
|
|
45
|
+
export declare function waitForRun(input: {
|
|
46
|
+
seconds: number;
|
|
47
|
+
terminalId?: string;
|
|
48
|
+
}, ports: {
|
|
49
|
+
now(): number;
|
|
50
|
+
pause(milliseconds: number): Promise<void>;
|
|
51
|
+
keepGoing(): Promise<boolean>;
|
|
52
|
+
job?(terminalId: string): Promise<RunJobStatus>;
|
|
53
|
+
}): Promise<RunWaitResult>;
|
|
54
|
+
/** Reads a `computer_terminal` status result. */
|
|
55
|
+
export declare function runJobStatus(output: unknown): RunJobStatus;
|
|
56
|
+
//# sourceMappingURL=run-wait.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-wait.d.ts","sourceRoot":"","sources":["../src/run-wait.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAG1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,CAAA;IAC1C,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC,CAAA;IAC7B,GAAG,CAAC,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAAA;CAChD,GACA,OAAO,CAAC,aAAa,CAAC,CAyBxB;AAED,iDAAiD;AACjD,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,GAAG,YAAY,CAQ1D"}
|
package/dist/run-wait.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { z } from 'zod/v3';
|
|
2
|
+
import { computerTerminalIdSchema } from './computer-tools.js';
|
|
3
|
+
/** One way for agents to wait without using model calls, shared by the cloud harness and private threads. */
|
|
4
|
+
export const RUN_WAIT_TOOL = 'harness_wait';
|
|
5
|
+
export const RUN_WAIT_MAX_SECONDS = 60 * 60;
|
|
6
|
+
/** Access is checked again, and Stop is noticed, at least this often. */
|
|
7
|
+
export const RUN_WAIT_CHECK_MAX_MS = 60_000;
|
|
8
|
+
export const RUN_WAIT_DESCRIPTION = 'Wait without using model calls: for a set time, or until a computer_terminal session ends. Use it for long builds, tests and renders '
|
|
9
|
+
+ 'instead of reading their output again and again. Start long work with computer_terminal, finish other independent work, tell the person '
|
|
10
|
+
+ 'what you are waiting for, then call this alone. With terminalId it returns soon after the command ends; seconds is the longest to wait. '
|
|
11
|
+
+ 'If the job is still running, call it again only if it is making progress. Do not wait for a server or watcher to end, or for the person: ask them instead.';
|
|
12
|
+
export const runWaitFields = {
|
|
13
|
+
seconds: z.number().int().min(5).max(RUN_WAIT_MAX_SECONDS).describe('How long to wait, at most. Up to 3600 (one hour) per call.'),
|
|
14
|
+
terminalId: computerTerminalIdSchema.optional().describe('Return early when this computer_terminal session ends'),
|
|
15
|
+
};
|
|
16
|
+
/** Quick checks at first, so short jobs return soon, then up to one a minute. */
|
|
17
|
+
export function runWaitDelay(check, remainingMs) {
|
|
18
|
+
return Math.max(1, Math.min(5_000 * 2 ** Math.min(check, 4), RUN_WAIT_CHECK_MAX_MS, remainingMs));
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The wait itself. `pause` is a durable sleep in the cloud and a timer on a person's computer; `keepGoing` renews the
|
|
22
|
+
* run and returns false once it was stopped.
|
|
23
|
+
*/
|
|
24
|
+
export async function waitForRun(input, ports) {
|
|
25
|
+
const startedAt = ports.now();
|
|
26
|
+
const deadline = startedAt + input.seconds * 1000;
|
|
27
|
+
const waited = () => Math.round((ports.now() - startedAt) / 1000);
|
|
28
|
+
if (input.terminalId && !ports.job) {
|
|
29
|
+
return { status: 'job_not_found', waitedSeconds: 0, message: 'Terminal sessions are not available in this run.' };
|
|
30
|
+
}
|
|
31
|
+
for (let check = 0;; check++) {
|
|
32
|
+
const job = input.terminalId ? await ports.job(input.terminalId) : null;
|
|
33
|
+
if (job?.state === 'ended') {
|
|
34
|
+
return { status: 'job_ended', waitedSeconds: waited(), exitCode: job.exitCode, message: 'Read its output with computer_terminal.' };
|
|
35
|
+
}
|
|
36
|
+
if (job?.state === 'computer_stopped') {
|
|
37
|
+
return { status: 'computer_stopped', waitedSeconds: waited(), message: 'The computer was stopped, so the job is no longer running and its output is gone. Nothing was restarted.' };
|
|
38
|
+
}
|
|
39
|
+
if (job?.state === 'not_found')
|
|
40
|
+
return { status: 'job_not_found', waitedSeconds: waited(), message: job.message };
|
|
41
|
+
const remaining = deadline - ports.now();
|
|
42
|
+
if (remaining <= 0) {
|
|
43
|
+
if (!job)
|
|
44
|
+
return { status: 'time_passed', waitedSeconds: waited() };
|
|
45
|
+
return job.state === 'running' ? { status: 'time_passed', waitedSeconds: waited(), jobRunning: true }
|
|
46
|
+
: { status: 'time_passed', waitedSeconds: waited(), message: `The job could not be checked: ${job.message}` };
|
|
47
|
+
}
|
|
48
|
+
await ports.pause(runWaitDelay(check, remaining));
|
|
49
|
+
if (!await ports.keepGoing())
|
|
50
|
+
return { status: 'stopped', waitedSeconds: waited() };
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/** Reads a `computer_terminal` status result. */
|
|
54
|
+
export function runJobStatus(output) {
|
|
55
|
+
const result = (output && typeof output === 'object' ? output : {});
|
|
56
|
+
const message = typeof result.message === 'string' ? result.message : typeof result.error === 'string' ? result.error : 'No answer from the computer.';
|
|
57
|
+
if (result.computerStopped === true)
|
|
58
|
+
return { state: 'computer_stopped' };
|
|
59
|
+
if (result.running === true)
|
|
60
|
+
return { state: 'running' };
|
|
61
|
+
if (result.running === false)
|
|
62
|
+
return { state: 'ended', exitCode: typeof result.exitCode === 'number' ? result.exitCode : null };
|
|
63
|
+
const code = typeof result.code === 'string' ? result.code : result.error;
|
|
64
|
+
return code === 'terminal_not_found' || code === 'invalid_input' ? { state: 'not_found', message } : { state: 'unavailable', message };
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=run-wait.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-wait.js","sourceRoot":"","sources":["../src/run-wait.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAC1B,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA;AAE9D,6GAA6G;AAC7G,MAAM,CAAC,MAAM,aAAa,GAAG,cAAc,CAAA;AAC3C,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,GAAG,EAAE,CAAA;AAC3C,yEAAyE;AACzE,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAA;AAE3C,MAAM,CAAC,MAAM,oBAAoB,GAC/B,uIAAuI;MACrI,0IAA0I;MAC1I,0IAA0I;MAC1I,4JAA4J,CAAA;AAEhK,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC,QAAQ,CAAC,4DAA4D,CAAC;IACjI,UAAU,EAAE,wBAAw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,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAA4B,CAAA;IAC9F,MAAM,OAAO,GAAG,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,MAAM,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,8BAA8B,CAAA;IACtJ,IAAI,MAAM,CAAC,eAAe,KAAK,IAAI;QAAE,OAAO,EAAE,KAAK,EAAE,kBAAkB,EAAE,CAAA;IACzE,IAAI,MAAM,CAAC,OAAO,KAAK,IAAI;QAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,CAAA;IACxD,IAAI,MAAM,CAAC,OAAO,KAAK,KAAK;QAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,MAAM,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;IAC/H,MAAM,IAAI,GAAG,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAA;IACzE,OAAO,IAAI,KAAK,oBAAoB,IAAI,IAAI,KAAK,eAAe,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,CAAA;AACxI,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@layernorm/overlay-agent-bridge-protocol",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Enrollment, signed host request and local tool contracts for the Overlay Agent Host.",
|
|
5
5
|
"license": "BUSL-1.1",
|
|
6
6
|
"repository": {
|
|
@@ -21,6 +21,21 @@
|
|
|
21
21
|
"types": "./dist/index.d.ts",
|
|
22
22
|
"import": "./dist/index.js",
|
|
23
23
|
"default": "./dist/index.js"
|
|
24
|
+
},
|
|
25
|
+
"./run-questions": {
|
|
26
|
+
"types": "./dist/run-questions.d.ts",
|
|
27
|
+
"import": "./dist/run-questions.js",
|
|
28
|
+
"default": "./dist/run-questions.js"
|
|
29
|
+
},
|
|
30
|
+
"./command-output-text": {
|
|
31
|
+
"types": "./dist/command-output-text.d.ts",
|
|
32
|
+
"import": "./dist/command-output-text.js",
|
|
33
|
+
"default": "./dist/command-output-text.js"
|
|
34
|
+
},
|
|
35
|
+
"./run-plan": {
|
|
36
|
+
"types": "./dist/run-plan.d.ts",
|
|
37
|
+
"import": "./dist/run-plan.js",
|
|
38
|
+
"default": "./dist/run-plan.js"
|
|
24
39
|
}
|
|
25
40
|
},
|
|
26
41
|
"files": [
|