@nyte-ai/plugin 0.0.24 → 0.0.25-nightly.20261025.2
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/THIRD-PARTY-NOTICES.md +13 -5
- package/dist/chunks/bash-description-0ah30s12.js +33 -0
- package/dist/chunks/{bash-description-qnwggxq3.js → bash-description-1neewp76.js} +19 -8
- package/dist/chunks/bash-description-4cdbmar0.js +124 -0
- package/dist/chunks/bash-description-4h0hnsv4.js +68 -0
- package/dist/chunks/bash-description-5dpf5hpt.js +724 -0
- package/dist/chunks/bash-description-9gw9ets8.js +162 -0
- package/dist/chunks/bash-description-b78pre8c.js +147 -0
- package/dist/chunks/{bash-description-necnb2k7.js → bash-description-vg0xecwm.js} +17 -7
- package/dist/src/acp/connection.js +1 -1
- package/dist/src/acp/index.d.ts +3 -3
- package/dist/src/acp/index.js +1 -1
- package/dist/src/approvals/approvals.d.ts +16 -16
- package/dist/src/approvals/schema.d.ts +18 -18
- package/dist/src/bash-description.d.ts +1 -1
- package/dist/src/bash-description.js +3 -5
- package/dist/src/canvas/canvas-protocol.d.ts +12 -12
- package/dist/src/canvas/canvas.d.ts +12 -3
- package/dist/src/canvas/canvas.js +33 -11
- package/dist/src/canvas/schema.d.ts +48 -8
- package/dist/src/canvas/schema.js +5 -1
- package/dist/src/claude-code-sdk/index.d.ts +1 -1
- package/dist/src/claude-code-sdk/index.js +1 -0
- package/dist/src/client/notifications.d.ts +1 -1
- package/dist/src/client/presentation.d.ts +1 -27
- package/dist/src/client/presentation.js +1 -19
- package/dist/src/codemode.js +148 -41
- package/dist/src/core.d.ts +1 -1
- package/dist/src/question/question.d.ts +14 -14
- package/dist/src/question/schema.d.ts +23 -23
- package/dist/src/rename.d.ts +17 -32
- package/dist/src/rename.js +115 -48
- package/dist/src/subagents.d.ts +30 -0
- package/dist/src/subagents.js +323 -0
- package/dist/src/telemetry.d.ts +1 -1
- package/dist/src/tool-search.d.ts +49 -0
- package/dist/src/tool-search.js +14 -0
- package/dist/src/web/body.d.ts +3 -0
- package/dist/src/web/body.js +6 -0
- package/dist/src/web/fetch.d.ts +16 -0
- package/dist/src/web/fetch.js +8 -0
- package/dist/src/web/html-markdown.d.ts +9 -0
- package/dist/src/web/html-markdown.js +10 -0
- package/dist/src/web/index.d.ts +24 -0
- package/dist/src/web/index.js +93 -0
- package/dist/src/web/providers.d.ts +60 -0
- package/dist/src/web/providers.js +11 -0
- package/dist/src/web/search.d.ts +21 -0
- package/dist/src/web/search.js +6 -0
- package/package.json +17 -9
- package/dist/src/web-search.d.ts +0 -78
- package/dist/src/web-search.js +0 -219
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { ToolDefinition } from "@nyte-ai/core";
|
|
2
2
|
export declare const question: import("@nyte-ai/core").PartDefinition<{
|
|
3
|
-
answers: string[][] | null;
|
|
4
3
|
questions: {
|
|
5
|
-
|
|
4
|
+
question: string;
|
|
5
|
+
header: string;
|
|
6
6
|
options: {
|
|
7
|
-
description: string;
|
|
8
7
|
label: string;
|
|
8
|
+
description: string;
|
|
9
9
|
}[];
|
|
10
|
-
|
|
11
|
-
header: string;
|
|
10
|
+
multiple?: boolean | undefined;
|
|
12
11
|
}[];
|
|
12
|
+
answers: string[][] | null;
|
|
13
13
|
}, {
|
|
14
14
|
answer: {
|
|
15
15
|
input: import("@nyte-ai/schema").Schema<{
|
|
@@ -28,16 +28,16 @@ declare const _default: {
|
|
|
28
28
|
id: string;
|
|
29
29
|
contribute: {
|
|
30
30
|
parts: import("@nyte-ai/core").PartDefinition<{
|
|
31
|
-
answers: string[][] | null;
|
|
32
31
|
questions: {
|
|
33
|
-
|
|
32
|
+
question: string;
|
|
33
|
+
header: string;
|
|
34
34
|
options: {
|
|
35
|
-
description: string;
|
|
36
35
|
label: string;
|
|
36
|
+
description: string;
|
|
37
37
|
}[];
|
|
38
|
-
|
|
39
|
-
header: string;
|
|
38
|
+
multiple?: boolean | undefined;
|
|
40
39
|
}[];
|
|
40
|
+
answers: string[][] | null;
|
|
41
41
|
}, {
|
|
42
42
|
answer: {
|
|
43
43
|
input: import("@nyte-ai/schema").Schema<{
|
|
@@ -47,13 +47,13 @@ declare const _default: {
|
|
|
47
47
|
}>[];
|
|
48
48
|
tools: ToolDefinition<{
|
|
49
49
|
questions: {
|
|
50
|
-
|
|
50
|
+
question: string;
|
|
51
|
+
header: string;
|
|
51
52
|
options: {
|
|
52
|
-
description: string;
|
|
53
53
|
label: string;
|
|
54
|
+
description: string;
|
|
54
55
|
}[];
|
|
55
|
-
|
|
56
|
-
header: string;
|
|
56
|
+
multiple?: boolean | undefined;
|
|
57
57
|
}[];
|
|
58
58
|
}, {
|
|
59
59
|
answers: string[][] | null;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { Infer, PartId, SessionView } from "@nyte-ai/schema";
|
|
2
2
|
declare const info: import("@nyte-ai/schema").Schema<{
|
|
3
|
-
|
|
3
|
+
question: string;
|
|
4
|
+
header: string;
|
|
4
5
|
options: {
|
|
5
|
-
description: string;
|
|
6
6
|
label: string;
|
|
7
|
+
description: string;
|
|
7
8
|
}[];
|
|
8
|
-
|
|
9
|
-
header: string;
|
|
9
|
+
multiple?: boolean | undefined;
|
|
10
10
|
}>;
|
|
11
11
|
export declare const answerInput: import("@nyte-ai/schema").Schema<{
|
|
12
12
|
answers: string[][];
|
|
@@ -15,26 +15,26 @@ export declare const questionOutput: import("@nyte-ai/schema").Schema<{
|
|
|
15
15
|
answers: string[][] | null;
|
|
16
16
|
}>;
|
|
17
17
|
declare const state: import("@nyte-ai/schema").Schema<{
|
|
18
|
-
answers: string[][] | null;
|
|
19
18
|
questions: {
|
|
20
|
-
|
|
19
|
+
question: string;
|
|
20
|
+
header: string;
|
|
21
21
|
options: {
|
|
22
|
-
description: string;
|
|
23
22
|
label: string;
|
|
23
|
+
description: string;
|
|
24
24
|
}[];
|
|
25
|
-
|
|
26
|
-
header: string;
|
|
25
|
+
multiple?: boolean | undefined;
|
|
27
26
|
}[];
|
|
27
|
+
answers: string[][] | null;
|
|
28
28
|
}>;
|
|
29
29
|
export declare const questionParameters: import("@nyte-ai/schema").Schema<{
|
|
30
30
|
questions: {
|
|
31
|
-
|
|
31
|
+
question: string;
|
|
32
|
+
header: string;
|
|
32
33
|
options: {
|
|
33
|
-
description: string;
|
|
34
34
|
label: string;
|
|
35
|
+
description: string;
|
|
35
36
|
}[];
|
|
36
|
-
|
|
37
|
-
header: string;
|
|
37
|
+
multiple?: boolean | undefined;
|
|
38
38
|
}[];
|
|
39
39
|
}>;
|
|
40
40
|
/** A question, its described choices, and whether the user may select several. */
|
|
@@ -53,16 +53,16 @@ export type QuestionState = Infer<typeof state>;
|
|
|
53
53
|
export declare const question: {
|
|
54
54
|
kind: string;
|
|
55
55
|
state: import("@nyte-ai/schema").Schema<{
|
|
56
|
-
answers: string[][] | null;
|
|
57
56
|
questions: {
|
|
58
|
-
|
|
57
|
+
question: string;
|
|
58
|
+
header: string;
|
|
59
59
|
options: {
|
|
60
|
-
description: string;
|
|
61
60
|
label: string;
|
|
61
|
+
description: string;
|
|
62
62
|
}[];
|
|
63
|
-
|
|
64
|
-
header: string;
|
|
63
|
+
multiple?: boolean | undefined;
|
|
65
64
|
}[];
|
|
65
|
+
answers: string[][] | null;
|
|
66
66
|
}>;
|
|
67
67
|
actions: {
|
|
68
68
|
answer: {
|
|
@@ -72,16 +72,16 @@ export declare const question: {
|
|
|
72
72
|
};
|
|
73
73
|
};
|
|
74
74
|
fallback: (current: {
|
|
75
|
-
answers: string[][] | null;
|
|
76
75
|
questions: {
|
|
77
|
-
|
|
76
|
+
question: string;
|
|
77
|
+
header: string;
|
|
78
78
|
options: {
|
|
79
|
-
description: string;
|
|
80
79
|
label: string;
|
|
80
|
+
description: string;
|
|
81
81
|
}[];
|
|
82
|
-
|
|
83
|
-
header: string;
|
|
82
|
+
multiple?: boolean | undefined;
|
|
84
83
|
}[];
|
|
84
|
+
answers: string[][] | null;
|
|
85
85
|
}, { id }: {
|
|
86
86
|
readonly id: PartId;
|
|
87
87
|
}) => string;
|
package/dist/src/rename.d.ts
CHANGED
|
@@ -1,52 +1,37 @@
|
|
|
1
|
+
import type { ToolDefinition } from "@nyte-ai/core";
|
|
1
2
|
import type { Command } from "@nyte-ai/plugin/core";
|
|
2
|
-
|
|
3
|
-
* The instruction a title request runs under: one short line in the user's
|
|
4
|
-
* language, naming what the conversation is about.
|
|
5
|
-
*
|
|
6
|
-
* @category plugins
|
|
7
|
-
* @since 0.1.0
|
|
8
|
-
*/
|
|
9
|
-
export declare const TITLE_PROMPT = "You write the title of a conversation so the user can find it later.\nAnswer with one line of at most 50 characters and nothing else, in the language of the user's request.\nName the topic or task, keep technical terms, numbers and file names exact, and never answer the request itself.";
|
|
10
|
-
/**
|
|
11
|
-
* Names an unnamed root session as its first run starts: the first line of
|
|
12
|
-
* the user's message at once, then the title one `api.request` to the
|
|
13
|
-
* session's model returns, alongside the run. The title replaces only that
|
|
14
|
-
* first line, so a name given meanwhile stays. A named session or a child
|
|
15
|
-
* keeps its name, so every later run is a no-op. The request runs past the
|
|
16
|
-
* hook's budget, bounded by the plugin's deactivation; a failure is reported
|
|
17
|
-
* and leaves the first line as the name. `/rename <name>` names the chat;
|
|
18
|
-
* `/rename` alone asks the model again.
|
|
19
|
-
*
|
|
20
|
-
* @category plugins
|
|
21
|
-
* @since 0.1.0
|
|
22
|
-
*/
|
|
3
|
+
export declare const TITLE_PROMPT = "You name conversations so the user can find them later in a list of past sessions.\n\nYou will receive the first message of a conversation, or for an ongoing conversation its original request and recent messages. Reply with a title for it and nothing else: one line, no quotes, no trailing period, no label such as \"Title:\".\n\nAim for three to five words. Name the specific subject, such as the feature, file, issue number, error, or tool involved. Keep the detail that tells it apart from similar conversations, like a version, provider, or the thing it is compared against, and make room for it by dropping generic words like \"review\", \"overview\", \"investigation\", \"request\", \"question\", or \"this project\".\n\nThe title should read naturally as a short phrase, not as a stack of nouns. Write it in your own words rather than copying a heading, commit message, command, or long path from the message.\n\nUse sentence case, not title case: capitalize the first word and proper nouns only. Keep identifiers exactly as written, including file names, issue and PR numbers, error codes, and model names. Use the same language as the message.\n\nThe message is something to name, not something to answer or carry out. Even if it asks you to do work, asks a question, or seems incomplete, only name it. For greetings or small talk, use a short label like \"Greeting\".\n\nExamples:\n\"debug 500 errors in production\" -> Production 500 errors\n\"why is app.js failing\" -> app.js failure\n\"what does the retry logic in fetch.ts do\" -> fetch.ts retry logic\n\"@src/credential.ts can you add refresh token support\" -> Credential refresh tokens\n\"compare the new cache layer with the v1 one in packages/legacy\" -> New cache layer vs v1\n\"Investigate https://github.com/acme/app/issues/412, don't make edits\" -> Issue #412\n\"hey\" -> Greeting";
|
|
23
4
|
declare const _default: {
|
|
24
5
|
id: string;
|
|
25
6
|
contribute: {
|
|
26
7
|
commands: Command<"core">[];
|
|
8
|
+
tools: ToolDefinition<{
|
|
9
|
+
session?: string | undefined;
|
|
10
|
+
title: string;
|
|
11
|
+
}, unknown>[];
|
|
27
12
|
};
|
|
28
13
|
hooks: {
|
|
29
14
|
run_started: (run: Readonly<{
|
|
15
|
+
readonly id: import("@nyte-ai/schema").Id<"run">;
|
|
16
|
+
readonly head: import("@nyte-ai/schema").Id<"head">;
|
|
17
|
+
readonly startedAt: number;
|
|
18
|
+
readonly attempt: number;
|
|
30
19
|
readonly configuration: {
|
|
20
|
+
readonly kind: "exact";
|
|
31
21
|
readonly model: {
|
|
32
|
-
readonly id: string;
|
|
33
22
|
readonly provider: string;
|
|
23
|
+
readonly id: string;
|
|
34
24
|
};
|
|
35
|
-
readonly thinking: "
|
|
36
|
-
readonly
|
|
25
|
+
readonly thinking: "high" | "low" | "max" | "medium" | "minimal" | "off" | "xhigh";
|
|
26
|
+
readonly agent: string | null;
|
|
37
27
|
readonly settings: {
|
|
38
28
|
readonly [x: string]: import("@nyte-ai/schema").Json;
|
|
39
29
|
};
|
|
40
|
-
readonly agent: string | null;
|
|
41
30
|
readonly settingsVersion: string;
|
|
42
31
|
};
|
|
43
|
-
readonly id: import("@nyte-ai/schema").Id<"run">;
|
|
44
|
-
readonly head: import("@nyte-ai/schema").Id<"head">;
|
|
45
|
-
readonly startedAt: number;
|
|
46
|
-
readonly attempt: number;
|
|
47
32
|
readonly origin: {
|
|
48
|
-
readonly message: import("@nyte-ai/schema").Id<"message">;
|
|
49
33
|
readonly kind: "input";
|
|
34
|
+
readonly message: import("@nyte-ai/schema").Id<"message">;
|
|
50
35
|
} | {
|
|
51
36
|
readonly kind: "continuation";
|
|
52
37
|
readonly from: "child" | "job" | "wake";
|
|
@@ -58,7 +43,7 @@ declare const _default: {
|
|
|
58
43
|
readonly contribute: import("@nyte-ai/core").Registries<"core">;
|
|
59
44
|
readonly storage: import("@nyte-ai/core").PluginStorage;
|
|
60
45
|
readonly signal: AbortSignal;
|
|
61
|
-
hook<N extends "
|
|
46
|
+
hook<N extends import("@nyte-ai/core").HookName<"core">>(name: N, entry: import("@nyte-ai/core").HookEntry<"core", N>): import("@nyte-ai/schema").Disposer;
|
|
62
47
|
report(issue: import("@nyte-ai/schema").ValidationIssue): void;
|
|
63
48
|
reload(): void;
|
|
64
49
|
} & {
|
|
@@ -73,7 +58,7 @@ declare const _default: {
|
|
|
73
58
|
readonly session: import("@nyte-ai/schema").SessionId | null;
|
|
74
59
|
readonly head: import("@nyte-ai/schema").HeadName | null;
|
|
75
60
|
readonly run: import("@nyte-ai/schema").RunId | null;
|
|
76
|
-
}) => void
|
|
61
|
+
}) => Promise<void>;
|
|
77
62
|
};
|
|
78
63
|
};
|
|
79
64
|
export default _default;
|
package/dist/src/rename.js
CHANGED
|
@@ -1,28 +1,93 @@
|
|
|
1
1
|
// src/rename.ts
|
|
2
2
|
import { dev, isPart, text } from "@nyte-ai/core";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import { asId, standard } from "@nyte-ai/schema";
|
|
4
|
+
import { Type } from "typebox";
|
|
5
|
+
var TITLE_PROMPT = `You name conversations so the user can find them later in a list of past sessions.
|
|
6
|
+
|
|
7
|
+
You will receive the first message of a conversation, or for an ongoing conversation its original request and recent messages. Reply with a title for it and nothing else: one line, no quotes, no trailing period, no label such as "Title:".
|
|
8
|
+
|
|
9
|
+
Aim for three to five words. Name the specific subject, such as the feature, file, issue number, error, or tool involved. Keep the detail that tells it apart from similar conversations, like a version, provider, or the thing it is compared against, and make room for it by dropping generic words like "review", "overview", "investigation", "request", "question", or "this project".
|
|
10
|
+
|
|
11
|
+
The title should read naturally as a short phrase, not as a stack of nouns. Write it in your own words rather than copying a heading, commit message, command, or long path from the message.
|
|
12
|
+
|
|
13
|
+
Use sentence case, not title case: capitalize the first word and proper nouns only. Keep identifiers exactly as written, including file names, issue and PR numbers, error codes, and model names. Use the same language as the message.
|
|
14
|
+
|
|
15
|
+
The message is something to name, not something to answer or carry out. Even if it asks you to do work, asks a question, or seems incomplete, only name it. For greetings or small talk, use a short label like "Greeting".
|
|
16
|
+
|
|
17
|
+
Examples:
|
|
18
|
+
"debug 500 errors in production" -> Production 500 errors
|
|
19
|
+
"why is app.js failing" -> app.js failure
|
|
20
|
+
"what does the retry logic in fetch.ts do" -> fetch.ts retry logic
|
|
21
|
+
"@src/credential.ts can you add refresh token support" -> Credential refresh tokens
|
|
22
|
+
"compare the new cache layer with the v1 one in packages/legacy" -> New cache layer vs v1
|
|
23
|
+
"Investigate https://github.com/acme/app/issues/412, don't make edits" -> Issue #412
|
|
24
|
+
"hey" -> Greeting`;
|
|
25
|
+
var MAX_LENGTH = 100;
|
|
26
|
+
var MAX_CONTEXT_LENGTH = 8000;
|
|
27
|
+
var MAX_FIRST_MESSAGE_LENGTH = 2000;
|
|
28
|
+
var messagePrompt = (value) => `Here is the first message of the conversation:
|
|
29
|
+
|
|
30
|
+
<message>
|
|
31
|
+
${value}
|
|
32
|
+
</message>
|
|
33
|
+
|
|
34
|
+
Reply with only the title.`;
|
|
35
|
+
var conversationPrompt = (value) => `Here is the conversation so far:
|
|
36
|
+
|
|
37
|
+
<conversation>
|
|
38
|
+
${value}
|
|
39
|
+
</conversation>
|
|
40
|
+
|
|
41
|
+
Reply with only the title.`;
|
|
7
42
|
var renameCommand = {
|
|
8
43
|
name: "rename",
|
|
9
44
|
title: "Rename chat",
|
|
10
45
|
description: "Names the chat; with no name, the chat's model titles it again.",
|
|
11
46
|
takesText: true,
|
|
12
47
|
async run(given, { api, signal }) {
|
|
13
|
-
const name = given
|
|
14
|
-
|
|
15
|
-
|
|
48
|
+
const name = given.trim();
|
|
49
|
+
if (name !== "") {
|
|
50
|
+
await api.session.update({ name });
|
|
51
|
+
return `Renamed to ${name}.`;
|
|
52
|
+
}
|
|
53
|
+
const title = await generateTitle(api, signal);
|
|
54
|
+
return title === null ? "The chat's model gave no title." : `Renamed to ${title}.`;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
var renameParameters = standard(Type.Object({
|
|
58
|
+
session: Type.Optional(Type.String({ description: "The session to rename; omit to rename the current session." })),
|
|
59
|
+
title: Type.String({ minLength: 1, description: "The new session title." })
|
|
60
|
+
}));
|
|
61
|
+
var renameTool = {
|
|
62
|
+
name: "session_rename",
|
|
63
|
+
description: "Rename a session, or omit session to rename the current session. Use a short, specific title that summarizes the work being done.",
|
|
64
|
+
parameters: renameParameters,
|
|
65
|
+
class: (args) => ({ kind: "custom", label: `Renaming to ${args.title.trim()}` }),
|
|
66
|
+
effects: "none",
|
|
67
|
+
approval: "never",
|
|
68
|
+
replay: "safe",
|
|
69
|
+
async execute(args, invocation) {
|
|
70
|
+
const id = args.session ?? invocation.session.id;
|
|
71
|
+
const title = args.title.trim();
|
|
72
|
+
if (title === "")
|
|
73
|
+
throw new Error("Session title must not be empty.");
|
|
74
|
+
const outcome = await invocation.sdk.session(asId(id)).update({ name: title });
|
|
75
|
+
if (outcome.kind !== "updated")
|
|
76
|
+
throw new Error(`Unable to rename session ${id}: ${outcome.kind}.`);
|
|
77
|
+
return { content: [{ kind: "text", text: `Renamed session ${id} to ${title}.` }] };
|
|
16
78
|
}
|
|
17
79
|
};
|
|
18
80
|
var rename_default = {
|
|
19
81
|
id: "rename",
|
|
20
|
-
contribute: { commands: [renameCommand] },
|
|
82
|
+
contribute: { commands: [renameCommand], tools: [renameTool] },
|
|
21
83
|
hooks: {
|
|
22
|
-
run_started: (run, { api }) => {
|
|
84
|
+
run_started: async (run, { api }) => {
|
|
23
85
|
if (run.origin.kind !== "input")
|
|
24
86
|
return;
|
|
25
|
-
|
|
87
|
+
const info = await api.session.info();
|
|
88
|
+
if (info.name !== null || info.parent !== null)
|
|
89
|
+
return;
|
|
90
|
+
generateTitle(api, api.signal).catch((error) => api.report({
|
|
26
91
|
severity: "warning",
|
|
27
92
|
path: ["run_started"],
|
|
28
93
|
message: `Naming the session failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -31,56 +96,58 @@ var rename_default = {
|
|
|
31
96
|
}
|
|
32
97
|
}
|
|
33
98
|
};
|
|
34
|
-
async function
|
|
35
|
-
const
|
|
36
|
-
if (info.name !== null || info.parent !== null)
|
|
37
|
-
return;
|
|
38
|
-
const view = await api.session.view();
|
|
39
|
-
const words = view.messages.flatMap((message) => message.kind === "user" ? [userWords(message.content)] : [])[0];
|
|
40
|
-
const firstLine = words?.split(`
|
|
41
|
-
`).find((line) => line.trim() !== "")?.trim().slice(0, NAME_LIMIT);
|
|
42
|
-
if (firstLine === undefined)
|
|
43
|
-
return;
|
|
44
|
-
await api.session.update({ name: firstLine });
|
|
45
|
-
const title = await requestTitle(api, api.signal);
|
|
46
|
-
if ((await api.session.info()).name !== firstLine)
|
|
47
|
-
return;
|
|
48
|
-
await api.session.update({ name: title });
|
|
49
|
-
}
|
|
50
|
-
async function requestTitle(api, signal) {
|
|
99
|
+
async function generateTitle(api, signal) {
|
|
100
|
+
const before = (await api.session.info()).name;
|
|
51
101
|
const view = await api.session.view();
|
|
52
102
|
const model = view.configuration.effective?.model;
|
|
53
|
-
const
|
|
54
|
-
if (model === undefined)
|
|
55
|
-
|
|
56
|
-
if (conversation === "")
|
|
57
|
-
throw new Error("Send a message before titling the chat.");
|
|
103
|
+
const first = view.messages.find((message) => message.kind === "user");
|
|
104
|
+
if (model === undefined || first === undefined)
|
|
105
|
+
return null;
|
|
58
106
|
const outcome = await api.request({
|
|
59
107
|
model,
|
|
60
108
|
system: TITLE_PROMPT,
|
|
61
|
-
messages: [
|
|
109
|
+
messages: [
|
|
110
|
+
{
|
|
111
|
+
role: "user",
|
|
112
|
+
content: before === null ? messagePrompt(userWords(first.content)) : historyPrompt(first, view.messages),
|
|
113
|
+
timestamp: Date.now()
|
|
114
|
+
}
|
|
115
|
+
],
|
|
62
116
|
maxOutput: 64,
|
|
63
117
|
signal
|
|
64
118
|
});
|
|
65
119
|
dev("rename", "title", { session: api.session.id, outcome: outcome.kind });
|
|
66
|
-
if (outcome.kind
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
120
|
+
if (outcome.kind !== "ok")
|
|
121
|
+
return null;
|
|
122
|
+
const line = outcome.value.split(`
|
|
123
|
+
`).map((candidate) => candidate.trim()).find((candidate) => candidate.length > 0);
|
|
124
|
+
if (line === undefined)
|
|
125
|
+
return null;
|
|
126
|
+
const title = line.length <= MAX_LENGTH ? line : `${line.slice(0, MAX_LENGTH - 3)}...`;
|
|
127
|
+
const current = (await api.session.info()).name;
|
|
128
|
+
if (current !== before || current === title)
|
|
129
|
+
return title;
|
|
130
|
+
await api.session.update({ name: title });
|
|
131
|
+
return title;
|
|
75
132
|
}
|
|
76
|
-
function
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
133
|
+
function historyPrompt(first, messages) {
|
|
134
|
+
const original = `Original request:
|
|
135
|
+
${userWords(first.content).slice(0, MAX_FIRST_MESSAGE_LENGTH)}`;
|
|
136
|
+
const recent = messages.flatMap((message) => {
|
|
137
|
+
if (message.kind === "user" && message !== first)
|
|
138
|
+
return [`User: ${userWords(message.content).trim()}`];
|
|
139
|
+
return isPart(message, text) && message.state.markdown.trim() !== "" ? [`Assistant: ${message.state.markdown.trim()}`] : [];
|
|
81
140
|
}).join(`
|
|
82
141
|
|
|
83
|
-
`)
|
|
142
|
+
`);
|
|
143
|
+
if (recent === "")
|
|
144
|
+
return conversationPrompt(original);
|
|
145
|
+
const prefix = `${original}
|
|
146
|
+
|
|
147
|
+
Recent conversation:
|
|
148
|
+
`;
|
|
149
|
+
const budget = MAX_CONTEXT_LENGTH - conversationPrompt("").length - prefix.length;
|
|
150
|
+
return conversationPrompt(`${prefix}${recent.slice(-budget)}`);
|
|
84
151
|
}
|
|
85
152
|
function userWords(content) {
|
|
86
153
|
return typeof content === "string" ? content : content.flatMap((block) => block.kind === "text" ? [block.text] : []).join(" ");
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Session } from "@nyte-ai/core";
|
|
2
|
+
/**
|
|
3
|
+
* Contributes the subagent tools to top-level sessions: `task`, `create`,
|
|
4
|
+
* `send`, `await`, `read_agent` and `stop`, built on child sessions and
|
|
5
|
+
* durable waits.
|
|
6
|
+
*
|
|
7
|
+
* @category plugins
|
|
8
|
+
* @since 0.1.0
|
|
9
|
+
*/
|
|
10
|
+
declare const _default: {
|
|
11
|
+
id: string;
|
|
12
|
+
activate(api: {
|
|
13
|
+
readonly side: "core";
|
|
14
|
+
readonly sdk: import("@nyte-ai/core").Connection;
|
|
15
|
+
readonly contribute: import("@nyte-ai/core").Registries<"core">;
|
|
16
|
+
readonly storage: import("@nyte-ai/core").PluginStorage;
|
|
17
|
+
readonly signal: AbortSignal;
|
|
18
|
+
hook<N extends import("@nyte-ai/core").HookName<"core">>(name: N, entry: import("@nyte-ai/core").HookEntry<"core", N>): import("@nyte-ai/schema").Disposer;
|
|
19
|
+
report(issue: import("@nyte-ai/schema").ValidationIssue): void;
|
|
20
|
+
reload(): void;
|
|
21
|
+
} & {
|
|
22
|
+
readonly session: Session;
|
|
23
|
+
readonly env: import("@nyte-ai/core").ExecutionEnv;
|
|
24
|
+
wrapEnv(wrap: import("@nyte-ai/core").EnvironmentWrap): import("@nyte-ai/schema").Disposer;
|
|
25
|
+
readonly inputs: import("@nyte-ai/core").Resources;
|
|
26
|
+
request<T = string>(input: import("@nyte-ai/schema").ModelRequestInput<T>): Promise<import("@nyte-ai/schema").ModelRequestOutcome<T>>;
|
|
27
|
+
approve(call: import("@nyte-ai/core").RuntimeCall, signal: AbortSignal): Promise<import("@nyte-ai/core").RuntimeVerdict>;
|
|
28
|
+
}): Promise<void>;
|
|
29
|
+
};
|
|
30
|
+
export default _default;
|