@prompty/core 2.0.0-alpha.4 → 2.0.0-alpha.5
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/index.cjs +20 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -5
- package/dist/index.d.ts +4 -5
- package/dist/index.js +18 -21
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -2141,7 +2141,7 @@ declare function load(path: string): Prompty;
|
|
|
2141
2141
|
* Four-step execution pipeline.
|
|
2142
2142
|
*
|
|
2143
2143
|
* ```
|
|
2144
|
-
*
|
|
2144
|
+
* invoke(prompt, inputs) → top-level orchestrator
|
|
2145
2145
|
* ├── prepare(agent, inputs) → template → wire format
|
|
2146
2146
|
* │ ├── render(agent, inputs) → template + inputs → rendered string
|
|
2147
2147
|
* │ └── parse(agent, rendered) → rendered string → Message[]
|
|
@@ -2191,7 +2191,7 @@ declare function run(agent: Prompty, messages: Message[], options?: {
|
|
|
2191
2191
|
/**
|
|
2192
2192
|
* Full pipeline: load → prepare → run.
|
|
2193
2193
|
*/
|
|
2194
|
-
declare function
|
|
2194
|
+
declare function invoke(prompt: string | Prompty, inputs?: Record<string, unknown>, options?: {
|
|
2195
2195
|
raw?: boolean;
|
|
2196
2196
|
}): Promise<unknown>;
|
|
2197
2197
|
/**
|
|
@@ -2204,12 +2204,11 @@ declare function resolveBindings(agent: Prompty, toolName: string, args: Record<
|
|
|
2204
2204
|
/**
|
|
2205
2205
|
* Run a prompt with automatic tool-call execution loop.
|
|
2206
2206
|
*/
|
|
2207
|
-
declare function
|
|
2207
|
+
declare function invokeAgent(prompt: string | Prompty, inputs?: Record<string, unknown>, options?: {
|
|
2208
2208
|
tools?: Record<string, (...args: unknown[]) => unknown>;
|
|
2209
2209
|
maxIterations?: number;
|
|
2210
2210
|
raw?: boolean;
|
|
2211
2211
|
}): Promise<unknown>;
|
|
2212
|
-
declare const runAgent: typeof executeAgent;
|
|
2213
2212
|
|
|
2214
2213
|
/**
|
|
2215
2214
|
* Nunjucks renderer — Jinja2-compatible template rendering for TypeScript.
|
|
@@ -2470,4 +2469,4 @@ interface OtelTracerOptions {
|
|
|
2470
2469
|
*/
|
|
2471
2470
|
declare function otelTracer(api: OtelApi, options?: OtelTracerOptions): TracerFactory;
|
|
2472
2471
|
|
|
2473
|
-
export { Prompty as AgentDefinition, AnonymousConnection, ApiKeyConnection, ArrayProperty, type AudioPart, Binding, Connection, type ContentPart, CustomTool, type Executor, type FilePart, FormatConfig, FoundryConnection, FunctionTool, type ImagePart, InvokerError, LoadContext, McpApprovalMode, McpTool, Message, Model, ModelOptions, MustacheRenderer, NunjucksRenderer, OAuthConnection, ObjectProperty, OpenApiTool, type OtelApi, type OtelTracerOptions, type Parser, ParserConfig, type Processor, Prompty as PromptAgent, Prompty, PromptyChatParser, PromptyStream, PromptyTool, PromptyTracer, Property, RICH_KINDS, ROLES, ReferenceConnection, RemoteConnection, type Renderer, type Role, SaveContext, type SpanEmitter, Template, type TextPart, ThreadMarker, Tool, type ToolCall, Tracer, type TracerBackend, type TracerFactory, clearCache, clearConnections, consoleTracer, dictContentToPart, dictToMessage,
|
|
2472
|
+
export { Prompty as AgentDefinition, AnonymousConnection, ApiKeyConnection, ArrayProperty, type AudioPart, Binding, Connection, type ContentPart, CustomTool, type Executor, type FilePart, FormatConfig, FoundryConnection, FunctionTool, type ImagePart, InvokerError, LoadContext, McpApprovalMode, McpTool, Message, Model, ModelOptions, MustacheRenderer, NunjucksRenderer, OAuthConnection, ObjectProperty, OpenApiTool, type OtelApi, type OtelTracerOptions, type Parser, ParserConfig, type Processor, Prompty as PromptAgent, Prompty, PromptyChatParser, PromptyStream, PromptyTool, PromptyTracer, Property, RICH_KINDS, ROLES, ReferenceConnection, RemoteConnection, type Renderer, type Role, SaveContext, type SpanEmitter, Template, type TextPart, ThreadMarker, Tool, type ToolCall, Tracer, type TracerBackend, type TracerFactory, clearCache, clearConnections, consoleTracer, dictContentToPart, dictToMessage, getConnection, getExecutor, getParser, getProcessor, getRenderer, invoke, invokeAgent, load, otelTracer, parse, prepare, process, registerConnection, registerExecutor, registerParser, registerProcessor, registerRenderer, render, resolveBindings, run, sanitizeValue, text, textMessage, toSerializable, trace, traceMethod, traceSpan, validateInputs };
|
package/dist/index.d.ts
CHANGED
|
@@ -2141,7 +2141,7 @@ declare function load(path: string): Prompty;
|
|
|
2141
2141
|
* Four-step execution pipeline.
|
|
2142
2142
|
*
|
|
2143
2143
|
* ```
|
|
2144
|
-
*
|
|
2144
|
+
* invoke(prompt, inputs) → top-level orchestrator
|
|
2145
2145
|
* ├── prepare(agent, inputs) → template → wire format
|
|
2146
2146
|
* │ ├── render(agent, inputs) → template + inputs → rendered string
|
|
2147
2147
|
* │ └── parse(agent, rendered) → rendered string → Message[]
|
|
@@ -2191,7 +2191,7 @@ declare function run(agent: Prompty, messages: Message[], options?: {
|
|
|
2191
2191
|
/**
|
|
2192
2192
|
* Full pipeline: load → prepare → run.
|
|
2193
2193
|
*/
|
|
2194
|
-
declare function
|
|
2194
|
+
declare function invoke(prompt: string | Prompty, inputs?: Record<string, unknown>, options?: {
|
|
2195
2195
|
raw?: boolean;
|
|
2196
2196
|
}): Promise<unknown>;
|
|
2197
2197
|
/**
|
|
@@ -2204,12 +2204,11 @@ declare function resolveBindings(agent: Prompty, toolName: string, args: Record<
|
|
|
2204
2204
|
/**
|
|
2205
2205
|
* Run a prompt with automatic tool-call execution loop.
|
|
2206
2206
|
*/
|
|
2207
|
-
declare function
|
|
2207
|
+
declare function invokeAgent(prompt: string | Prompty, inputs?: Record<string, unknown>, options?: {
|
|
2208
2208
|
tools?: Record<string, (...args: unknown[]) => unknown>;
|
|
2209
2209
|
maxIterations?: number;
|
|
2210
2210
|
raw?: boolean;
|
|
2211
2211
|
}): Promise<unknown>;
|
|
2212
|
-
declare const runAgent: typeof executeAgent;
|
|
2213
2212
|
|
|
2214
2213
|
/**
|
|
2215
2214
|
* Nunjucks renderer — Jinja2-compatible template rendering for TypeScript.
|
|
@@ -2470,4 +2469,4 @@ interface OtelTracerOptions {
|
|
|
2470
2469
|
*/
|
|
2471
2470
|
declare function otelTracer(api: OtelApi, options?: OtelTracerOptions): TracerFactory;
|
|
2472
2471
|
|
|
2473
|
-
export { Prompty as AgentDefinition, AnonymousConnection, ApiKeyConnection, ArrayProperty, type AudioPart, Binding, Connection, type ContentPart, CustomTool, type Executor, type FilePart, FormatConfig, FoundryConnection, FunctionTool, type ImagePart, InvokerError, LoadContext, McpApprovalMode, McpTool, Message, Model, ModelOptions, MustacheRenderer, NunjucksRenderer, OAuthConnection, ObjectProperty, OpenApiTool, type OtelApi, type OtelTracerOptions, type Parser, ParserConfig, type Processor, Prompty as PromptAgent, Prompty, PromptyChatParser, PromptyStream, PromptyTool, PromptyTracer, Property, RICH_KINDS, ROLES, ReferenceConnection, RemoteConnection, type Renderer, type Role, SaveContext, type SpanEmitter, Template, type TextPart, ThreadMarker, Tool, type ToolCall, Tracer, type TracerBackend, type TracerFactory, clearCache, clearConnections, consoleTracer, dictContentToPart, dictToMessage,
|
|
2472
|
+
export { Prompty as AgentDefinition, AnonymousConnection, ApiKeyConnection, ArrayProperty, type AudioPart, Binding, Connection, type ContentPart, CustomTool, type Executor, type FilePart, FormatConfig, FoundryConnection, FunctionTool, type ImagePart, InvokerError, LoadContext, McpApprovalMode, McpTool, Message, Model, ModelOptions, MustacheRenderer, NunjucksRenderer, OAuthConnection, ObjectProperty, OpenApiTool, type OtelApi, type OtelTracerOptions, type Parser, ParserConfig, type Processor, Prompty as PromptAgent, Prompty, PromptyChatParser, PromptyStream, PromptyTool, PromptyTracer, Property, RICH_KINDS, ROLES, ReferenceConnection, RemoteConnection, type Renderer, type Role, SaveContext, type SpanEmitter, Template, type TextPart, ThreadMarker, Tool, type ToolCall, Tracer, type TracerBackend, type TracerFactory, clearCache, clearConnections, consoleTracer, dictContentToPart, dictToMessage, getConnection, getExecutor, getParser, getProcessor, getRenderer, invoke, invokeAgent, load, otelTracer, parse, prepare, process, registerConnection, registerExecutor, registerParser, registerProcessor, registerRenderer, render, resolveBindings, run, sanitizeValue, text, textMessage, toSerializable, trace, traceMethod, traceSpan, validateInputs };
|
package/dist/index.js
CHANGED
|
@@ -4567,14 +4567,14 @@ var init_tool_dispatch = __esm({
|
|
|
4567
4567
|
async executeTool(tool, _args, _agent, _parentInputs) {
|
|
4568
4568
|
const name = tool.name ?? "unknown";
|
|
4569
4569
|
throw new Error(
|
|
4570
|
-
`Function tool '${name}' declared but no callable provided. Pass it via tools: { '${name}': fn } in
|
|
4570
|
+
`Function tool '${name}' declared but no callable provided. Pass it via tools: { '${name}': fn } in invokeAgent().`
|
|
4571
4571
|
);
|
|
4572
4572
|
}
|
|
4573
4573
|
};
|
|
4574
4574
|
PromptyToolHandler = class {
|
|
4575
4575
|
async executeTool(tool, args, agent, _parentInputs) {
|
|
4576
4576
|
const { load: load2 } = await Promise.resolve().then(() => (init_loader(), loader_exports));
|
|
4577
|
-
const { prepare: prepare2, run: run2,
|
|
4577
|
+
const { prepare: prepare2, run: run2, invokeAgent: invokeAgent2 } = await Promise.resolve().then(() => (init_pipeline(), pipeline_exports));
|
|
4578
4578
|
const parentPath = (agent.metadata ?? {}).__source_path;
|
|
4579
4579
|
if (!parentPath) {
|
|
4580
4580
|
return `Error: cannot resolve PromptyTool '${tool.name}': parent has no __source_path`;
|
|
@@ -4593,7 +4593,7 @@ var init_tool_dispatch = __esm({
|
|
|
4593
4593
|
child.metadata.__prompty_tool_stack = [...stack, parentPath];
|
|
4594
4594
|
const mode = tool.mode ?? "single";
|
|
4595
4595
|
if (mode === "agentic") {
|
|
4596
|
-
const result = await
|
|
4596
|
+
const result = await invokeAgent2(child, args);
|
|
4597
4597
|
return typeof result === "string" ? result : JSON.stringify(result);
|
|
4598
4598
|
} else {
|
|
4599
4599
|
const messages = await prepare2(child, args);
|
|
@@ -4631,15 +4631,14 @@ var init_tool_dispatch = __esm({
|
|
|
4631
4631
|
// src/core/pipeline.ts
|
|
4632
4632
|
var pipeline_exports = {};
|
|
4633
4633
|
__export(pipeline_exports, {
|
|
4634
|
-
|
|
4635
|
-
|
|
4634
|
+
invoke: () => invoke,
|
|
4635
|
+
invokeAgent: () => invokeAgent,
|
|
4636
4636
|
parse: () => parse,
|
|
4637
4637
|
prepare: () => prepare,
|
|
4638
4638
|
process: () => process2,
|
|
4639
4639
|
render: () => render,
|
|
4640
4640
|
resolveBindings: () => resolveBindings,
|
|
4641
4641
|
run: () => run,
|
|
4642
|
-
runAgent: () => runAgent,
|
|
4643
4642
|
validateInputs: () => validateInputs
|
|
4644
4643
|
});
|
|
4645
4644
|
function sanitizeNonces(value) {
|
|
@@ -4816,8 +4815,8 @@ async function run(agent, messages, options) {
|
|
|
4816
4815
|
return result;
|
|
4817
4816
|
});
|
|
4818
4817
|
}
|
|
4819
|
-
async function
|
|
4820
|
-
return traceSpan("
|
|
4818
|
+
async function invoke(prompt, inputs, options) {
|
|
4819
|
+
return traceSpan("invoke", async (emit) => {
|
|
4821
4820
|
const agent = typeof prompt === "string" ? await traceSpan("load", async (loadEmit) => {
|
|
4822
4821
|
loadEmit("signature", "prompty.load");
|
|
4823
4822
|
loadEmit("description", "Load a prompty file.");
|
|
@@ -4826,8 +4825,8 @@ async function execute(prompt, inputs, options) {
|
|
|
4826
4825
|
loadEmit("result", serializeAgent(loaded));
|
|
4827
4826
|
return loaded;
|
|
4828
4827
|
}) : prompt;
|
|
4829
|
-
emit("signature", "prompty.
|
|
4830
|
-
emit("description", "
|
|
4828
|
+
emit("signature", "prompty.invoke");
|
|
4829
|
+
emit("description", "Invoke a prompty");
|
|
4831
4830
|
emit("inputs", { prompt: serializeAgent(agent), inputs: inputs ?? {} });
|
|
4832
4831
|
const messages = await prepare(agent, inputs);
|
|
4833
4832
|
const result = await run(agent, messages, options);
|
|
@@ -4951,8 +4950,8 @@ async function buildToolMessagesFromCalls(toolCalls, textContent, tools, agent,
|
|
|
4951
4950
|
}
|
|
4952
4951
|
return messages;
|
|
4953
4952
|
}
|
|
4954
|
-
async function
|
|
4955
|
-
return traceSpan("
|
|
4953
|
+
async function invokeAgent(prompt, inputs, options) {
|
|
4954
|
+
return traceSpan("invokeAgent", async (emit) => {
|
|
4956
4955
|
const agent = typeof prompt === "string" ? await traceSpan("load", async (loadEmit) => {
|
|
4957
4956
|
loadEmit("signature", "prompty.load");
|
|
4958
4957
|
loadEmit("description", "Load a prompty file.");
|
|
@@ -4963,8 +4962,8 @@ async function executeAgent(prompt, inputs, options) {
|
|
|
4963
4962
|
}) : prompt;
|
|
4964
4963
|
const tools = options?.tools ?? {};
|
|
4965
4964
|
const maxIterations = options?.maxIterations ?? DEFAULT_MAX_ITERATIONS;
|
|
4966
|
-
emit("signature", "prompty.
|
|
4967
|
-
emit("description", "
|
|
4965
|
+
emit("signature", "prompty.invokeAgent");
|
|
4966
|
+
emit("description", "Invoke a prompty with tool calling");
|
|
4968
4967
|
emit("inputs", { prompt: serializeAgent(agent), tools: Object.keys(tools), inputs: inputs ?? {} });
|
|
4969
4968
|
const messages = await prepare(agent, inputs);
|
|
4970
4969
|
const parentInputs = inputs ?? {};
|
|
@@ -4987,7 +4986,7 @@ async function executeAgent(prompt, inputs, options) {
|
|
|
4987
4986
|
);
|
|
4988
4987
|
}
|
|
4989
4988
|
const toolMessages2 = await traceSpan("toolCalls", async (toolEmit) => {
|
|
4990
|
-
toolEmit("signature", "prompty.
|
|
4989
|
+
toolEmit("signature", "prompty.invokeAgent.toolCalls");
|
|
4991
4990
|
toolEmit("description", `Tool call round ${iteration}`);
|
|
4992
4991
|
const result2 = await buildToolMessagesFromCalls(toolCalls, content, tools, agent, parentInputs, toolEmit);
|
|
4993
4992
|
toolEmit("result", result2.map((m) => ({ role: m.role, content: m.parts.map((p) => p.value ?? "").join(""), metadata: m.metadata })));
|
|
@@ -5005,7 +5004,7 @@ async function executeAgent(prompt, inputs, options) {
|
|
|
5005
5004
|
);
|
|
5006
5005
|
}
|
|
5007
5006
|
const toolMessages = await traceSpan("toolCalls", async (toolEmit) => {
|
|
5008
|
-
toolEmit("signature", "prompty.
|
|
5007
|
+
toolEmit("signature", "prompty.invokeAgent.toolCalls");
|
|
5009
5008
|
toolEmit("description", `Tool call round ${iteration}`);
|
|
5010
5009
|
const result2 = await buildToolResultMessages(response, tools, agent, parentInputs, toolEmit);
|
|
5011
5010
|
toolEmit("result", result2.map((m) => ({ role: m.role, content: m.parts.map((p) => p.value ?? "").join(""), metadata: m.metadata })));
|
|
@@ -5244,7 +5243,7 @@ async function buildResponsesToolResultMessages(r, tools, agent, parentInputs, p
|
|
|
5244
5243
|
}
|
|
5245
5244
|
return messages;
|
|
5246
5245
|
}
|
|
5247
|
-
var DEFAULT_FORMAT, DEFAULT_PARSER, DEFAULT_PROVIDER, DEFAULT_MAX_ITERATIONS
|
|
5246
|
+
var DEFAULT_FORMAT, DEFAULT_PARSER, DEFAULT_PROVIDER, DEFAULT_MAX_ITERATIONS;
|
|
5248
5247
|
var init_pipeline = __esm({
|
|
5249
5248
|
"src/core/pipeline.ts"() {
|
|
5250
5249
|
"use strict";
|
|
@@ -5258,7 +5257,6 @@ var init_pipeline = __esm({
|
|
|
5258
5257
|
DEFAULT_PARSER = "prompty";
|
|
5259
5258
|
DEFAULT_PROVIDER = "openai";
|
|
5260
5259
|
DEFAULT_MAX_ITERATIONS = 10;
|
|
5261
|
-
runAgent = executeAgent;
|
|
5262
5260
|
}
|
|
5263
5261
|
});
|
|
5264
5262
|
|
|
@@ -5719,13 +5717,13 @@ export {
|
|
|
5719
5717
|
consoleTracer,
|
|
5720
5718
|
dictContentToPart,
|
|
5721
5719
|
dictToMessage,
|
|
5722
|
-
execute,
|
|
5723
|
-
executeAgent,
|
|
5724
5720
|
getConnection,
|
|
5725
5721
|
getExecutor,
|
|
5726
5722
|
getParser,
|
|
5727
5723
|
getProcessor,
|
|
5728
5724
|
getRenderer,
|
|
5725
|
+
invoke,
|
|
5726
|
+
invokeAgent,
|
|
5729
5727
|
load,
|
|
5730
5728
|
otelTracer,
|
|
5731
5729
|
parse,
|
|
@@ -5739,7 +5737,6 @@ export {
|
|
|
5739
5737
|
render,
|
|
5740
5738
|
resolveBindings,
|
|
5741
5739
|
run,
|
|
5742
|
-
runAgent,
|
|
5743
5740
|
sanitizeValue,
|
|
5744
5741
|
text,
|
|
5745
5742
|
textMessage,
|