dsh-agy-cli 0.0.0-stage → 0.12.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 +30 -0
- package/README.en.md +27 -0
- package/README.md +94 -2
- package/agents/dsh-agy-image-view.md +17 -0
- package/agents/dsh-agy-mcp-executor.md +32 -0
- package/agents/dsh-agy-read-only.md +20 -0
- package/agents/dsh-agy-tool-free.md +16 -0
- package/agents/dsh-agy-workspace-write.md +23 -0
- package/bin/dsh-agy-cli.js +9 -0
- package/bin/win32-x64/agy-launcher.exe +0 -0
- package/cordis.patch.yml +16 -0
- package/dist/client.js +4259 -0
- package/lib/agent-installer.d.ts +66 -0
- package/lib/agent-installer.js +147 -0
- package/lib/agent-presets.d.ts +42 -0
- package/lib/agent-presets.js +130 -0
- package/lib/agents-cli.d.ts +3 -0
- package/lib/agents-cli.js +110 -0
- package/lib/agy/diagnostics.d.ts +29 -0
- package/lib/agy/diagnostics.js +109 -0
- package/lib/agy/errors.d.ts +20 -0
- package/lib/agy/errors.js +77 -0
- package/lib/agy/experimental-transport.d.ts +79 -0
- package/lib/agy/experimental-transport.js +612 -0
- package/lib/agy/keepalive.d.ts +140 -0
- package/lib/agy/keepalive.js +424 -0
- package/lib/agy/limiter.d.ts +32 -0
- package/lib/agy/limiter.js +111 -0
- package/lib/agy/log.d.ts +214 -0
- package/lib/agy/log.js +503 -0
- package/lib/agy/models.d.ts +49 -0
- package/lib/agy/models.js +203 -0
- package/lib/agy/overrides.d.ts +17 -0
- package/lib/agy/overrides.js +73 -0
- package/lib/agy/parser.d.ts +102 -0
- package/lib/agy/parser.js +492 -0
- package/lib/agy/persistent-transport.d.ts +101 -0
- package/lib/agy/persistent-transport.js +753 -0
- package/lib/agy/process.d.ts +144 -0
- package/lib/agy/process.js +452 -0
- package/lib/agy/redact.d.ts +3 -0
- package/lib/agy/redact.js +24 -0
- package/lib/agy/stream-protocol.d.ts +50 -0
- package/lib/agy/stream-protocol.js +156 -0
- package/lib/agy/windows-launcher.d.ts +21 -0
- package/lib/agy/windows-launcher.js +76 -0
- package/lib/diagnostics.d.ts +78 -0
- package/lib/diagnostics.js +162 -0
- package/lib/doctor.d.ts +138 -0
- package/lib/doctor.js +923 -0
- package/lib/dsh/context.d.ts +133 -0
- package/lib/dsh/context.js +352 -0
- package/lib/dsh-home.d.ts +6 -0
- package/lib/dsh-home.js +11 -0
- package/lib/index.d.ts +43 -0
- package/lib/index.js +256 -0
- package/lib/mcp/agy-registration.d.ts +70 -0
- package/lib/mcp/agy-registration.js +245 -0
- package/lib/mcp/bridge.d.ts +73 -0
- package/lib/mcp/bridge.js +295 -0
- package/lib/mcp/endpoint.d.ts +41 -0
- package/lib/mcp/endpoint.js +142 -0
- package/lib/mcp/protocol.d.ts +107 -0
- package/lib/mcp/protocol.js +197 -0
- package/lib/mcp/tool-projection.d.ts +64 -0
- package/lib/mcp/tool-projection.js +168 -0
- package/lib/provider/agy.d.ts +153 -0
- package/lib/provider/agy.js +2159 -0
- package/lib/provider/config.d.ts +226 -0
- package/lib/provider/config.js +294 -0
- package/lib/provider/error-codes.d.ts +22 -0
- package/lib/provider/error-codes.js +29 -0
- package/lib/provider/image-bridge.d.ts +60 -0
- package/lib/provider/image-bridge.js +290 -0
- package/lib/provider/mock.d.ts +15 -0
- package/lib/provider/mock.js +78 -0
- package/lib/provider/prompt-budget.d.ts +45 -0
- package/lib/provider/prompt-budget.js +596 -0
- package/lib/provider/serialize.d.ts +15 -0
- package/lib/provider/serialize.js +82 -0
- package/lib/provider/tool-protocol.d.ts +80 -0
- package/lib/provider/tool-protocol.js +848 -0
- package/lib/provider/tool-schema-file.d.ts +11 -0
- package/lib/provider/tool-schema-file.js +27 -0
- package/lib/session/file-store.d.ts +56 -0
- package/lib/session/file-store.js +186 -0
- package/lib/session/store.d.ts +49 -0
- package/lib/session/store.js +62 -0
- package/lib/web/router.d.ts +19 -0
- package/lib/web/router.js +906 -0
- package/package.json +112 -4
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
export class AgyPromptError extends Error {
|
|
2
|
+
code;
|
|
3
|
+
constructor(message, code) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.code = code;
|
|
6
|
+
this.name = 'AgyPromptError';
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
function blockText(block, messageIndex, blockIndex) {
|
|
10
|
+
switch (block.type) {
|
|
11
|
+
case 'text':
|
|
12
|
+
return block.text;
|
|
13
|
+
case 'reasoning':
|
|
14
|
+
return `[reasoning]\n${block.text}`;
|
|
15
|
+
case 'tool-call':
|
|
16
|
+
return `[DSH TOOL CALL]\n${JSON.stringify({
|
|
17
|
+
id: block.id,
|
|
18
|
+
name: block.name,
|
|
19
|
+
arguments: block.arguments,
|
|
20
|
+
})}`;
|
|
21
|
+
default:
|
|
22
|
+
throw new AgyPromptError(`AGY text MVP does not support content block ${block.type} at message ${messageIndex}, block ${blockIndex}`, 'UNSUPPORTED_CONTENT');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function blockValue(block, messageIndex, blockIndex) {
|
|
26
|
+
switch (block.type) {
|
|
27
|
+
case 'text':
|
|
28
|
+
return { type: 'text', text: block.text };
|
|
29
|
+
case 'reasoning':
|
|
30
|
+
return { type: 'reasoning', text: block.text };
|
|
31
|
+
case 'tool-call':
|
|
32
|
+
return { type: 'tool-call', id: block.id, name: block.name, arguments: block.arguments };
|
|
33
|
+
default:
|
|
34
|
+
throw new AgyPromptError(`AGY text MVP does not support content block ${block.type} at message ${messageIndex}, block ${blockIndex}`, 'UNSUPPORTED_CONTENT');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function messageText(message, messageIndex) {
|
|
38
|
+
// 0.2.0 moved tool results out of content blocks into a first-class tool-role
|
|
39
|
+
// message; the flat text prompt keeps the same [DSH TOOL RESULT] rendering.
|
|
40
|
+
if (message.role === 'tool') {
|
|
41
|
+
return `[DSH TOOL RESULT]\n${JSON.stringify({
|
|
42
|
+
callId: message.toolCallId,
|
|
43
|
+
isError: message.isError === true,
|
|
44
|
+
content: message.content.map((block, blockIndex) => blockValue(block, messageIndex, String(blockIndex))),
|
|
45
|
+
})}`;
|
|
46
|
+
}
|
|
47
|
+
return message.content
|
|
48
|
+
.map((block, blockIndex) => blockText(block, messageIndex, blockIndex))
|
|
49
|
+
.join('\n');
|
|
50
|
+
}
|
|
51
|
+
function roleLabel(message) {
|
|
52
|
+
return message.role.toUpperCase();
|
|
53
|
+
}
|
|
54
|
+
/** Serialize the DSH request into a deterministic, text-only AGY prompt. */
|
|
55
|
+
export function serializeAgyPrompt(options) {
|
|
56
|
+
const sections = [];
|
|
57
|
+
if (options.system !== undefined && options.system.length > 0) {
|
|
58
|
+
sections.push(`=== SYSTEM ===\n${options.system}`);
|
|
59
|
+
}
|
|
60
|
+
options.messages.forEach((message, messageIndex) => {
|
|
61
|
+
sections.push(`=== ${roleLabel(message)} ===\n${messageText(message, messageIndex)}`);
|
|
62
|
+
});
|
|
63
|
+
if (sections.length === 0) {
|
|
64
|
+
throw new AgyPromptError('AGY text MVP requires a non-empty system or message prompt', 'EMPTY_PROMPT');
|
|
65
|
+
}
|
|
66
|
+
return sections.join('\n\n');
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Serialize only the messages added after the previous assistant turn.
|
|
70
|
+
* AGY already owns the earlier turns when `--conversation` is used; sending
|
|
71
|
+
* the complete DSH history again would duplicate context and spend quota.
|
|
72
|
+
*/
|
|
73
|
+
export function serializeAgyTurnPrompt(options) {
|
|
74
|
+
let lastAssistant = -1;
|
|
75
|
+
options.messages.forEach((message, index) => {
|
|
76
|
+
if (message.role === 'assistant')
|
|
77
|
+
lastAssistant = index;
|
|
78
|
+
});
|
|
79
|
+
const messages = options.messages.slice(lastAssistant + 1);
|
|
80
|
+
return serializeAgyPrompt({ messages });
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=serialize.js.map
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { ToolSchema } from '@deepseek-ai/dsh-llm';
|
|
2
|
+
/** Upper bounds for the provider-side structured tool protocol. */
|
|
3
|
+
export declare const TOOL_PROTOCOL_LIMITS: Readonly<{
|
|
4
|
+
maxTools: 256;
|
|
5
|
+
maxToolNameLength: 128;
|
|
6
|
+
maxDescriptionLength: 4096;
|
|
7
|
+
maxSchemaDepth: 10;
|
|
8
|
+
maxSchemaBytes: number;
|
|
9
|
+
maxArgumentsBytes: number;
|
|
10
|
+
maxMessageLength: number;
|
|
11
|
+
maxResultBytes: number;
|
|
12
|
+
maxPromptContractBytes: number;
|
|
13
|
+
}>;
|
|
14
|
+
export declare const TOOL_PROTOCOL_SCHEMA_INVALID_CODE: "TOOL_PROTOCOL_SCHEMA_INVALID";
|
|
15
|
+
export declare const TOOL_PROTOCOL_SCHEMA_LIMIT_CODE: "TOOL_PROTOCOL_SCHEMA_LIMIT";
|
|
16
|
+
export declare const TOOL_PROTOCOL_RESPONSE_INVALID_CODE: "TOOL_PROTOCOL_RESPONSE_INVALID";
|
|
17
|
+
export declare const TOOL_PROTOCOL_UNKNOWN_TOOL_CODE: "TOOL_PROTOCOL_UNKNOWN_TOOL";
|
|
18
|
+
export declare const TOOL_PROTOCOL_ARGUMENTS_INVALID_CODE: "TOOL_PROTOCOL_ARGUMENTS_INVALID";
|
|
19
|
+
export declare const TOOL_PROTOCOL_RESPONSE_LIMIT_CODE: "TOOL_PROTOCOL_RESPONSE_LIMIT";
|
|
20
|
+
export type ToolProtocolErrorCode = typeof TOOL_PROTOCOL_ARGUMENTS_INVALID_CODE | typeof TOOL_PROTOCOL_RESPONSE_INVALID_CODE | typeof TOOL_PROTOCOL_RESPONSE_LIMIT_CODE | typeof TOOL_PROTOCOL_SCHEMA_INVALID_CODE | typeof TOOL_PROTOCOL_SCHEMA_LIMIT_CODE | typeof TOOL_PROTOCOL_UNKNOWN_TOOL_CODE;
|
|
21
|
+
/** Safe, value-free diagnosis for a rejected tool argument object. */
|
|
22
|
+
export type ToolProtocolArgumentIssue = 'missing-required' | 'unexpected-property' | 'type' | 'enum' | 'constraint' | 'combinator' | 'unknown';
|
|
23
|
+
export interface ToolProtocolArgumentDiagnostic {
|
|
24
|
+
readonly toolName: string;
|
|
25
|
+
readonly issue: ToolProtocolArgumentIssue;
|
|
26
|
+
readonly path?: string;
|
|
27
|
+
readonly missingRequiredKeys?: readonly string[];
|
|
28
|
+
readonly receivedArgumentKeys?: readonly string[];
|
|
29
|
+
}
|
|
30
|
+
export type ToolProtocolCompatibility = 'pwsh-description-default' | 'json-control-character-escape' | 'agy-call-envelope' | 'agy-command-envelope' | 'agy-thought-call-envelope' | 'agy-bare-call-envelope';
|
|
31
|
+
export interface ParseStructuredEnvelopeOptions {
|
|
32
|
+
readonly onCompatibilityApplied?: (compatibility: ToolProtocolCompatibility) => void;
|
|
33
|
+
}
|
|
34
|
+
/** Stable error that never embeds raw prompts, arguments, schemas, or paths. */
|
|
35
|
+
export declare class ToolProtocolError extends Error {
|
|
36
|
+
readonly code: ToolProtocolErrorCode;
|
|
37
|
+
readonly detail: string | undefined;
|
|
38
|
+
readonly diagnostic: ToolProtocolArgumentDiagnostic | undefined;
|
|
39
|
+
constructor(code: ToolProtocolErrorCode, detail?: string, diagnostic?: ToolProtocolArgumentDiagnostic);
|
|
40
|
+
}
|
|
41
|
+
export type StructuredEnvelope = {
|
|
42
|
+
readonly kind: 'message';
|
|
43
|
+
readonly content: string;
|
|
44
|
+
} | {
|
|
45
|
+
readonly kind: 'tool_call';
|
|
46
|
+
readonly name: string;
|
|
47
|
+
readonly arguments: Record<string, unknown>;
|
|
48
|
+
};
|
|
49
|
+
export interface StructuredToolProtocol {
|
|
50
|
+
readonly schema: Record<string, unknown>;
|
|
51
|
+
readonly schemaJson: string;
|
|
52
|
+
/** SHA-256 of the canonical schema JSON; safe to emit as diagnostics. */
|
|
53
|
+
readonly schemaHash: string;
|
|
54
|
+
readonly tools: readonly ToolSchema[];
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Whitelist one JSON Schema down to the keywords the DSH tool protocol
|
|
58
|
+
* supports. Exported so the MCP tool projection can reuse exactly the same
|
|
59
|
+
* gate instead of duplicating the keyword policy.
|
|
60
|
+
*/
|
|
61
|
+
export declare function sanitizeSchema(value: unknown, depth: number, label: string): unknown;
|
|
62
|
+
/** Render the DSH-owned protocol as bounded data inside an AGY text prompt. */
|
|
63
|
+
export declare function renderToolProtocolPrompt(protocol: StructuredToolProtocol): string;
|
|
64
|
+
/** Append the immutable protocol contract after the serialized DSH history. */
|
|
65
|
+
export declare function appendToolProtocolPrompt(prompt: string, protocol: StructuredToolProtocol): string;
|
|
66
|
+
export type ToolProtocolRepairReason = 'internal-tool-event';
|
|
67
|
+
/** Add one bounded repair instruction after the protocol contract. */
|
|
68
|
+
export declare function appendToolProtocolRepairPrompt(prompt: string, hint?: Pick<ToolProtocolArgumentDiagnostic, 'toolName' | 'issue' | 'missingRequiredKeys'>, reason?: ToolProtocolRepairReason): string;
|
|
69
|
+
/** Convert DSH tool schemas into one strict, bounded AGY final-result schema. */
|
|
70
|
+
export declare function createStructuredToolProtocol(tools: readonly ToolSchema[]): StructuredToolProtocol;
|
|
71
|
+
/** Strictly parse and validate AGY's final structured response. */
|
|
72
|
+
export declare function parseStructuredEnvelope(raw: unknown, protocolOrTools: StructuredToolProtocol | readonly ToolSchema[], options?: ParseStructuredEnvelopeOptions): StructuredEnvelope;
|
|
73
|
+
/** Accumulate fragmented AGY result text without accepting an early partial JSON value. */
|
|
74
|
+
export declare class StructuredResponseAccumulator {
|
|
75
|
+
private text;
|
|
76
|
+
append(fragment: string): void;
|
|
77
|
+
parse(protocolOrTools: StructuredToolProtocol | readonly ToolSchema[]): StructuredEnvelope;
|
|
78
|
+
get length(): number;
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=tool-protocol.d.ts.map
|