@poncho-ai/harness 0.42.0 → 0.43.1

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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @poncho-ai/harness@0.42.0 build /home/runner/work/poncho-ai/poncho-ai/packages/harness
2
+ > @poncho-ai/harness@0.43.1 build /home/runner/work/poncho-ai/poncho-ai/packages/harness
3
3
  > node scripts/embed-docs.js && tsup src/index.ts --format esm --dts
4
4
 
5
5
  [embed-docs] Generated poncho-docs.ts with 4 topics
@@ -8,9 +8,9 @@
8
8
  CLI tsup v8.5.1
9
9
  CLI Target: es2022
10
10
  ESM Build start
11
- ESM dist/index.js 504.78 KB
11
+ ESM dist/index.js 506.50 KB
12
12
  ESM dist/isolate-VY35DGLM.js 49.43 KB
13
- ESM ⚡️ Build success in 228ms
13
+ ESM ⚡️ Build success in 164ms
14
14
  DTS Build start
15
- DTS ⚡️ Build success in 7856ms
16
- DTS dist/index.d.ts 79.11 KB
15
+ DTS ⚡️ Build success in 6912ms
16
+ DTS dist/index.d.ts 80.85 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,57 @@
1
1
  # @poncho-ai/harness
2
2
 
3
+ ## 0.43.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`134fae7`](https://github.com/cesr/poncho-ai/commit/134fae7eb4f3658b8d2dc0a5e560b0bcad094679) Thanks [@cesr](https://github.com/cesr)! - fix(harness): conversations.search now works on Postgres
8
+
9
+ The SQL for `engine.conversations.search()` matched `data LIKE $3`, but
10
+ `data` is a `jsonb` column in Postgres — `jsonb LIKE text` raises
11
+ `operator does not exist: jsonb ~~ unknown` (Postgres error 42883), so
12
+ every search call against a Postgres-backed engine 500'd at runtime.
13
+
14
+ Cast `data` to text in the Postgres branch (`data::text LIKE $3`).
15
+ SQLite stores `data` as TEXT-of-JSON, so no cast there.
16
+
17
+ Discovered while wiring `GET /me/conversations/search` in PonchOS.
18
+
19
+ ## 0.43.0
20
+
21
+ ### Minor Changes
22
+
23
+ - [`ff89631`](https://github.com/cesr/poncho-ai/commit/ff89631715e54d6fdce174943e6e0fc9e4ce5d1e) Thanks [@cesr](https://github.com/cesr)! - harness: export `defaultAgentDefinition` so SDK consumers can match `poncho init` exactly
24
+
25
+ Lifts the `AGENT_TEMPLATE` markdown body from `@poncho-ai/cli` (where it lived
26
+ inside the `init` scaffolding) into a public helper on `@poncho-ai/harness`.
27
+ SDK consumers (PonchOS, custom servers, anyone calling
28
+ `new AgentHarness({ agentDefinition })` directly) can now do:
29
+
30
+ ```ts
31
+ import { defaultAgentDefinition } from "@poncho-ai/harness";
32
+
33
+ const harness = new AgentHarness({
34
+ agentDefinition: defaultAgentDefinition({
35
+ name: "poncho",
36
+ modelName: "claude-sonnet-4-6",
37
+ }),
38
+ // ... storageEngine, config, etc.
39
+ });
40
+ ```
41
+
42
+ This eliminates hand-copying the template — drift between consumers and
43
+ `poncho init` is no longer possible.
44
+
45
+ The CLI's `AGENT_TEMPLATE` export is preserved as a thin back-compat
46
+ wrapper that delegates to `defaultAgentDefinition`. No behavior change.
47
+
48
+ API additions (harness):
49
+ - `defaultAgentDefinition(opts?: DefaultAgentDefinitionOptions): string`
50
+ - `DefaultAgentDefinitionOptions`
51
+ - `DEFAULT_AGENT_NAME`, `DEFAULT_AGENT_DESCRIPTION`,
52
+ `DEFAULT_MODEL_PROVIDER`, `DEFAULT_MODEL_NAME`, `DEFAULT_TEMPERATURE`,
53
+ `DEFAULT_MAX_STEPS`, `DEFAULT_TIMEOUT` constants
54
+
3
55
  ## 0.42.0
4
56
 
5
57
  ### Minor Changes
package/dist/index.d.ts CHANGED
@@ -685,6 +685,43 @@ declare const resolveStateConfig: (config: PonchoConfig | undefined) => StateCon
685
685
  declare const resolveMemoryConfig: (config: PonchoConfig | undefined) => MemoryConfig | undefined;
686
686
  declare const loadPonchoConfig: (workingDir: string) => Promise<PonchoConfig | undefined>;
687
687
 
688
+ interface DefaultAgentDefinitionOptions {
689
+ /** Display name for the agent. Default: "agent". */
690
+ name?: string;
691
+ /**
692
+ * Stable identifier embedded in the frontmatter. Default: a fresh
693
+ * `agent_<32hex>`. Note: when an injected `StorageEngine` is also passed
694
+ * to `AgentHarness`, the engine's `agentId` overrides this at runtime, so
695
+ * SDK consumers can leave it default.
696
+ */
697
+ id?: string;
698
+ /** Frontmatter description. Default: "A helpful Poncho assistant". */
699
+ description?: string;
700
+ /** Model provider. Default: "anthropic". */
701
+ modelProvider?: "anthropic" | "openai" | "openai-codex";
702
+ /** Model name. Default: "claude-opus-4-5". */
703
+ modelName?: string;
704
+ /** Sampling temperature. Default: 0.2. */
705
+ temperature?: number;
706
+ /** Max tool-call steps per run. Default: 20. */
707
+ maxSteps?: number;
708
+ /** Hard timeout in seconds. Default: 300. */
709
+ timeout?: number;
710
+ }
711
+ declare const DEFAULT_AGENT_NAME = "agent";
712
+ declare const DEFAULT_AGENT_DESCRIPTION = "A helpful Poncho assistant";
713
+ declare const DEFAULT_MODEL_PROVIDER: "anthropic";
714
+ declare const DEFAULT_MODEL_NAME = "claude-opus-4-5";
715
+ declare const DEFAULT_TEMPERATURE = 0.2;
716
+ declare const DEFAULT_MAX_STEPS = 20;
717
+ declare const DEFAULT_TIMEOUT = 300;
718
+ /**
719
+ * Returns the canonical default agent definition as a markdown string,
720
+ * ready to pass to `new AgentHarness({ agentDefinition })`. This is the
721
+ * exact same template `poncho init` writes to `AGENT.md`.
722
+ */
723
+ declare const defaultAgentDefinition: (opts?: DefaultAgentDefinitionOptions) => string;
724
+
688
725
  declare const createDefaultTools: (workingDir: string) => ToolDefinition[];
689
726
  declare const createWriteTool: (workingDir: string) => ToolDefinition;
690
727
  declare const createEditTool: (workingDir: string) => ToolDefinition;
@@ -1925,4 +1962,4 @@ interface RunConversationTurnResult {
1925
1962
  }
1926
1963
  declare const runConversationTurn: (opts: RunConversationTurnOpts) => Promise<RunConversationTurnResult>;
1927
1964
 
1928
- export { type ActiveConversationRun, type ActiveSubagentRun, type AgentFrontmatter, AgentHarness, type AgentIdentity, type AgentLimitsConfig, type AgentModelConfig, AgentOrchestrator, type ApprovalEventItem, type ArchivedToolResult$1 as ArchivedToolResult, type BashConfig, BashEnvironmentManager, type BashExecutionLimits, type BuiltInToolToggles, CALLBACK_LOCK_STALE_MS, type CompactMessagesOptions, type CompactResult, type CompactionConfig, type ContinuationHooks, type Conversation, type ConversationCreateInit, type ConversationState, type ConversationStatusSnapshot, type ConversationStore, type ConversationSummary, type CreateSkillToolsOptions, type CronJobConfig, type EventSink, type ExecuteTurnResult, type HarnessOptions, type HarnessRunOutput, type HistorySource, InMemoryConversationStore, InMemoryEngine, InMemoryStateStore, type IsolateBinding, type IsolateConfig, LocalMcpBridge, LocalUploadStore, MAX_CONCURRENT_SUBAGENTS, MAX_CONTINUATION_COUNT, MAX_SUBAGENT_CALLBACK_COUNT, MAX_SUBAGENT_NESTING, type MainMemory, type McpConfig, type MemoryConfig, type MemoryStore, type MessagingChannelConfig, type ModelProviderFactory, type NetworkConfig, OPENAI_CODEX_CLIENT_ID, type OpenAICodexAuthConfig, type OpenAICodexDeviceAuthRequest, type OpenAICodexSession, type OrchestratorHooks, type OrchestratorOptions, type OtlpConfig, type OtlpOption, PONCHO_UPLOAD_SCHEME, type ParsedAgent, type PendingSubagentApproval, type PendingSubagentResult, type PendingToolCall, type PonchoConfig, PonchoFsAdapter, PostgresEngine, type ProviderConfig, type Recurrence, type RecurrenceType, type Reminder, type ReminderCreateInput, type ReminderStatus, type ReminderStore, type RemoteMcpServerConfig, type RunConversationTurnOpts, type RunConversationTurnResult, type RunOutcome, type RunRequest, type RuntimeRenderContext, S3UploadStore, STALE_SUBAGENT_THRESHOLD_MS, STORAGE_SCHEMA_VERSION, type SecretsStore, type SkillContextEntry, type SkillMetadata, type SkillSource, SqliteEngine, type StateConfig, type StateProviderName, type StateStore, type StorageConfig, type StorageEngine, type StorageFactoryOptions, type StorageProvider, type StoredApproval, type SubagentManager, type SubagentResult, type SubagentSpawnResult, type SubagentSummary, TOOL_RESULT_ARCHIVE_PARAM, type TelemetryConfig, TelemetryEmitter, type TenantTokenPayload, type ToolAccess, type ToolCall, ToolDispatcher, type ToolExecutionResult, type TurnDraftState, type TurnResultMetadata, type TurnSection, type UploadStore, type UploadsConfig, VFS_SCHEME, VercelBlobUploadStore, type VfsDirEntry, type VfsStat, applyTurnMetadata, buildAgentDirectoryName, buildApprovalCheckpoints, buildAssistantMetadata, buildSkillContextWindow, buildToolCompletedText, cloneSections, compactMessages, completeOpenAICodexDeviceAuth, computeNextOccurrence, createBashTool, createConversationStore, createConversationStoreFromEngine, createDefaultTools, createDeleteDirectoryTool, createDeleteTool, createEditTool, createMemoryStore, createMemoryStoreFromEngine, createMemoryTools, createModelProvider, createReminderStore, createReminderStoreFromEngine, createReminderTools, createSearchTools, createSecretsStore, createSkillTools, createStateStore, createStorageEngine, createSubagentTools, createTodoStoreFromEngine, createTurnDraftState, createUploadStore, createWriteTool, deleteOpenAICodexSession, deriveUploadKey, ensureAgentIdentity, estimateTokens, estimateTotalTokens, executeConversationTurn, findSafeSplitPoint, flushTurnDraft, generateAgentId, getAgentStoreDirectory, getModelContextWindow, getOpenAICodexAccessToken, getOpenAICodexAuthFilePath, getOpenAICodexRequiredScopes, getPonchoStoreRoot, isMessageArray, jsonSchemaToZod, loadCanonicalHistory, loadPonchoConfig, loadRunHistory, loadSkillContext, loadSkillInstructions, loadSkillMetadata, loadVfsSkillMetadata, mergeSkills, normalizeApprovalCheckpoint, normalizeOtlp, normalizeScriptPolicyPath, parseAgentFile, parseAgentMarkdown, parseSkillFrontmatter, ponchoDocsTool, readOpenAICodexSession, readSkillResource, recordStandardTurnEvent, renderAgentPrompt, resolveAgentIdentity, resolveCompactionConfig, resolveEnv, resolveMemoryConfig, resolveRunRequest, resolveSkillDirs, resolveStateConfig, runConversationTurn, slugifyStorageComponent, startOpenAICodexDeviceAuth, verifyTenantToken, withToolResultArchiveParam, writeOpenAICodexSession };
1965
+ export { type ActiveConversationRun, type ActiveSubagentRun, type AgentFrontmatter, AgentHarness, type AgentIdentity, type AgentLimitsConfig, type AgentModelConfig, AgentOrchestrator, type ApprovalEventItem, type ArchivedToolResult$1 as ArchivedToolResult, type BashConfig, BashEnvironmentManager, type BashExecutionLimits, type BuiltInToolToggles, CALLBACK_LOCK_STALE_MS, type CompactMessagesOptions, type CompactResult, type CompactionConfig, type ContinuationHooks, type Conversation, type ConversationCreateInit, type ConversationState, type ConversationStatusSnapshot, type ConversationStore, type ConversationSummary, type CreateSkillToolsOptions, type CronJobConfig, DEFAULT_AGENT_DESCRIPTION, DEFAULT_AGENT_NAME, DEFAULT_MAX_STEPS, DEFAULT_MODEL_NAME, DEFAULT_MODEL_PROVIDER, DEFAULT_TEMPERATURE, DEFAULT_TIMEOUT, type DefaultAgentDefinitionOptions, type EventSink, type ExecuteTurnResult, type HarnessOptions, type HarnessRunOutput, type HistorySource, InMemoryConversationStore, InMemoryEngine, InMemoryStateStore, type IsolateBinding, type IsolateConfig, LocalMcpBridge, LocalUploadStore, MAX_CONCURRENT_SUBAGENTS, MAX_CONTINUATION_COUNT, MAX_SUBAGENT_CALLBACK_COUNT, MAX_SUBAGENT_NESTING, type MainMemory, type McpConfig, type MemoryConfig, type MemoryStore, type MessagingChannelConfig, type ModelProviderFactory, type NetworkConfig, OPENAI_CODEX_CLIENT_ID, type OpenAICodexAuthConfig, type OpenAICodexDeviceAuthRequest, type OpenAICodexSession, type OrchestratorHooks, type OrchestratorOptions, type OtlpConfig, type OtlpOption, PONCHO_UPLOAD_SCHEME, type ParsedAgent, type PendingSubagentApproval, type PendingSubagentResult, type PendingToolCall, type PonchoConfig, PonchoFsAdapter, PostgresEngine, type ProviderConfig, type Recurrence, type RecurrenceType, type Reminder, type ReminderCreateInput, type ReminderStatus, type ReminderStore, type RemoteMcpServerConfig, type RunConversationTurnOpts, type RunConversationTurnResult, type RunOutcome, type RunRequest, type RuntimeRenderContext, S3UploadStore, STALE_SUBAGENT_THRESHOLD_MS, STORAGE_SCHEMA_VERSION, type SecretsStore, type SkillContextEntry, type SkillMetadata, type SkillSource, SqliteEngine, type StateConfig, type StateProviderName, type StateStore, type StorageConfig, type StorageEngine, type StorageFactoryOptions, type StorageProvider, type StoredApproval, type SubagentManager, type SubagentResult, type SubagentSpawnResult, type SubagentSummary, TOOL_RESULT_ARCHIVE_PARAM, type TelemetryConfig, TelemetryEmitter, type TenantTokenPayload, type ToolAccess, type ToolCall, ToolDispatcher, type ToolExecutionResult, type TurnDraftState, type TurnResultMetadata, type TurnSection, type UploadStore, type UploadsConfig, VFS_SCHEME, VercelBlobUploadStore, type VfsDirEntry, type VfsStat, applyTurnMetadata, buildAgentDirectoryName, buildApprovalCheckpoints, buildAssistantMetadata, buildSkillContextWindow, buildToolCompletedText, cloneSections, compactMessages, completeOpenAICodexDeviceAuth, computeNextOccurrence, createBashTool, createConversationStore, createConversationStoreFromEngine, createDefaultTools, createDeleteDirectoryTool, createDeleteTool, createEditTool, createMemoryStore, createMemoryStoreFromEngine, createMemoryTools, createModelProvider, createReminderStore, createReminderStoreFromEngine, createReminderTools, createSearchTools, createSecretsStore, createSkillTools, createStateStore, createStorageEngine, createSubagentTools, createTodoStoreFromEngine, createTurnDraftState, createUploadStore, createWriteTool, defaultAgentDefinition, deleteOpenAICodexSession, deriveUploadKey, ensureAgentIdentity, estimateTokens, estimateTotalTokens, executeConversationTurn, findSafeSplitPoint, flushTurnDraft, generateAgentId, getAgentStoreDirectory, getModelContextWindow, getOpenAICodexAccessToken, getOpenAICodexAuthFilePath, getOpenAICodexRequiredScopes, getPonchoStoreRoot, isMessageArray, jsonSchemaToZod, loadCanonicalHistory, loadPonchoConfig, loadRunHistory, loadSkillContext, loadSkillInstructions, loadSkillMetadata, loadVfsSkillMetadata, mergeSkills, normalizeApprovalCheckpoint, normalizeOtlp, normalizeScriptPolicyPath, parseAgentFile, parseAgentMarkdown, parseSkillFrontmatter, ponchoDocsTool, readOpenAICodexSession, readSkillResource, recordStandardTurnEvent, renderAgentPrompt, resolveAgentIdentity, resolveCompactionConfig, resolveEnv, resolveMemoryConfig, resolveRunRequest, resolveSkillDirs, resolveStateConfig, runConversationTurn, slugifyStorageComponent, startOpenAICodexDeviceAuth, verifyTenantToken, withToolResultArchiveParam, writeOpenAICodexSession };
package/dist/index.js CHANGED
@@ -565,6 +565,53 @@ var loadPonchoConfig = async (workingDir) => {
565
565
  }
566
566
  };
567
567
 
568
+ // src/default-agent.ts
569
+ import { randomBytes } from "crypto";
570
+ var DEFAULT_AGENT_NAME = "agent";
571
+ var DEFAULT_AGENT_DESCRIPTION = "A helpful Poncho assistant";
572
+ var DEFAULT_MODEL_PROVIDER = "anthropic";
573
+ var DEFAULT_MODEL_NAME = "claude-opus-4-5";
574
+ var DEFAULT_TEMPERATURE = 0.2;
575
+ var DEFAULT_MAX_STEPS = 20;
576
+ var DEFAULT_TIMEOUT = 300;
577
+ var defaultAgentDefinition = (opts = {}) => {
578
+ const name = opts.name ?? DEFAULT_AGENT_NAME;
579
+ const id = opts.id ?? `agent_${randomBytes(16).toString("hex")}`;
580
+ const description = opts.description ?? DEFAULT_AGENT_DESCRIPTION;
581
+ const modelProvider = opts.modelProvider ?? DEFAULT_MODEL_PROVIDER;
582
+ const modelName = opts.modelName ?? DEFAULT_MODEL_NAME;
583
+ const temperature = opts.temperature ?? DEFAULT_TEMPERATURE;
584
+ const maxSteps = opts.maxSteps ?? DEFAULT_MAX_STEPS;
585
+ const timeout = opts.timeout ?? DEFAULT_TIMEOUT;
586
+ return `---
587
+ name: ${name}
588
+ id: ${id}
589
+ description: ${description}
590
+ model:
591
+ provider: ${modelProvider}
592
+ name: ${modelName}
593
+ temperature: ${temperature}
594
+ limits:
595
+ maxSteps: ${maxSteps}
596
+ timeout: ${timeout}
597
+ ---
598
+
599
+ # {{name}}
600
+
601
+ You are **{{name}}**, a helpful assistant built with Poncho.
602
+
603
+ Working directory: {{runtime.workingDir}}
604
+ Environment: {{runtime.environment}}
605
+
606
+ ## Task Guidance
607
+
608
+ - Use tools when needed
609
+ - Explain your reasoning clearly
610
+ - Ask clarifying questions when requirements are ambiguous
611
+ - Never claim a file/tool change unless the corresponding tool call actually succeeded
612
+ `;
613
+ };
614
+
568
615
  // src/default-tools.ts
569
616
  import { mkdir, readdir, readFile as readFile3, rm, unlink, writeFile as writeFile2 } from "fs/promises";
570
617
  import { dirname, resolve as resolve4, sep } from "path";
@@ -3654,11 +3701,12 @@ var SqlStorageEngine = class {
3654
3701
  const filterTenant = tenantId !== void 0;
3655
3702
  const pattern = `%${query}%`;
3656
3703
  const params = [this.agentId, pattern, pattern];
3704
+ const dataMatch = this.dialect.tag === "postgresql" ? "data::text LIKE $3" : "data LIKE $3";
3657
3705
  let sql = `SELECT id, title, updated_at, created_at, owner_id, tenant_id,
3658
3706
  message_count, parent_conversation_id, parent_message_id,
3659
3707
  has_pending_approvals, channel_meta
3660
3708
  FROM conversations
3661
- WHERE agent_id = $1 AND (title LIKE $2 OR data LIKE $3)`;
3709
+ WHERE agent_id = $1 AND (title LIKE $2 OR ${dataMatch})`;
3662
3710
  if (filterTenant) {
3663
3711
  sql += ` AND tenant_id = $4`;
3664
3712
  params.push(tid);
@@ -5562,14 +5610,14 @@ var createTodoTools = (store) => {
5562
5610
  };
5563
5611
 
5564
5612
  // src/secrets-store.ts
5565
- import { createCipheriv, createDecipheriv, randomBytes, createHash as createHash3 } from "crypto";
5613
+ import { createCipheriv, createDecipheriv, randomBytes as randomBytes2, createHash as createHash3 } from "crypto";
5566
5614
  import { mkdir as mkdir3, readFile as readFile5, writeFile as writeFile4 } from "fs/promises";
5567
5615
  import { dirname as dirname3, resolve as resolve7 } from "path";
5568
5616
  function deriveKey(signingKey) {
5569
5617
  return createHash3("sha256").update("poncho-secrets-v1:" + signingKey).digest();
5570
5618
  }
5571
5619
  function encrypt(plaintext, key) {
5572
- const iv = randomBytes(12);
5620
+ const iv = randomBytes2(12);
5573
5621
  const cipher = createCipheriv("aes-256-gcm", key, iv);
5574
5622
  const ct = Buffer.concat([cipher.update(plaintext, "utf8"), cipher.final()]);
5575
5623
  const tag = cipher.getAuthTag();
@@ -13307,6 +13355,13 @@ export {
13307
13355
  AgentOrchestrator,
13308
13356
  BashEnvironmentManager,
13309
13357
  CALLBACK_LOCK_STALE_MS,
13358
+ DEFAULT_AGENT_DESCRIPTION,
13359
+ DEFAULT_AGENT_NAME,
13360
+ DEFAULT_MAX_STEPS,
13361
+ DEFAULT_MODEL_NAME,
13362
+ DEFAULT_MODEL_PROVIDER,
13363
+ DEFAULT_TEMPERATURE,
13364
+ DEFAULT_TIMEOUT,
13310
13365
  InMemoryConversationStore,
13311
13366
  InMemoryEngine,
13312
13367
  InMemoryStateStore,
@@ -13363,6 +13418,7 @@ export {
13363
13418
  createTurnDraftState,
13364
13419
  createUploadStore,
13365
13420
  createWriteTool,
13421
+ defaultAgentDefinition,
13366
13422
  defineTool13 as defineTool,
13367
13423
  deleteOpenAICodexSession,
13368
13424
  deriveUploadKey,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@poncho-ai/harness",
3
- "version": "0.42.0",
3
+ "version": "0.43.1",
4
4
  "description": "Agent execution runtime - conversation loop, tool dispatch, streaming",
5
5
  "repository": {
6
6
  "type": "git",
@@ -0,0 +1,89 @@
1
+ // ---------------------------------------------------------------------------
2
+ // Canonical default agent definition.
3
+ //
4
+ // This is the same agent.md a fresh `poncho init` produces. The CLI's
5
+ // AGENT_TEMPLATE in `packages/cli/src/templates.ts` delegates to this helper
6
+ // so there is exactly one source of truth, and SDK consumers (PonchOS, custom
7
+ // servers, etc.) can pass the same default to `new AgentHarness({ agentDefinition: ... })`
8
+ // without hand-copying the template.
9
+ // ---------------------------------------------------------------------------
10
+
11
+ import { randomBytes } from "node:crypto";
12
+
13
+ export interface DefaultAgentDefinitionOptions {
14
+ /** Display name for the agent. Default: "agent". */
15
+ name?: string;
16
+ /**
17
+ * Stable identifier embedded in the frontmatter. Default: a fresh
18
+ * `agent_<32hex>`. Note: when an injected `StorageEngine` is also passed
19
+ * to `AgentHarness`, the engine's `agentId` overrides this at runtime, so
20
+ * SDK consumers can leave it default.
21
+ */
22
+ id?: string;
23
+ /** Frontmatter description. Default: "A helpful Poncho assistant". */
24
+ description?: string;
25
+ /** Model provider. Default: "anthropic". */
26
+ modelProvider?: "anthropic" | "openai" | "openai-codex";
27
+ /** Model name. Default: "claude-opus-4-5". */
28
+ modelName?: string;
29
+ /** Sampling temperature. Default: 0.2. */
30
+ temperature?: number;
31
+ /** Max tool-call steps per run. Default: 20. */
32
+ maxSteps?: number;
33
+ /** Hard timeout in seconds. Default: 300. */
34
+ timeout?: number;
35
+ }
36
+
37
+ export const DEFAULT_AGENT_NAME = "agent";
38
+ export const DEFAULT_AGENT_DESCRIPTION = "A helpful Poncho assistant";
39
+ export const DEFAULT_MODEL_PROVIDER = "anthropic" as const;
40
+ export const DEFAULT_MODEL_NAME = "claude-opus-4-5";
41
+ export const DEFAULT_TEMPERATURE = 0.2;
42
+ export const DEFAULT_MAX_STEPS = 20;
43
+ export const DEFAULT_TIMEOUT = 300;
44
+
45
+ /**
46
+ * Returns the canonical default agent definition as a markdown string,
47
+ * ready to pass to `new AgentHarness({ agentDefinition })`. This is the
48
+ * exact same template `poncho init` writes to `AGENT.md`.
49
+ */
50
+ export const defaultAgentDefinition = (
51
+ opts: DefaultAgentDefinitionOptions = {},
52
+ ): string => {
53
+ const name = opts.name ?? DEFAULT_AGENT_NAME;
54
+ const id = opts.id ?? `agent_${randomBytes(16).toString("hex")}`;
55
+ const description = opts.description ?? DEFAULT_AGENT_DESCRIPTION;
56
+ const modelProvider = opts.modelProvider ?? DEFAULT_MODEL_PROVIDER;
57
+ const modelName = opts.modelName ?? DEFAULT_MODEL_NAME;
58
+ const temperature = opts.temperature ?? DEFAULT_TEMPERATURE;
59
+ const maxSteps = opts.maxSteps ?? DEFAULT_MAX_STEPS;
60
+ const timeout = opts.timeout ?? DEFAULT_TIMEOUT;
61
+
62
+ return `---
63
+ name: ${name}
64
+ id: ${id}
65
+ description: ${description}
66
+ model:
67
+ provider: ${modelProvider}
68
+ name: ${modelName}
69
+ temperature: ${temperature}
70
+ limits:
71
+ maxSteps: ${maxSteps}
72
+ timeout: ${timeout}
73
+ ---
74
+
75
+ # {{name}}
76
+
77
+ You are **{{name}}**, a helpful assistant built with Poncho.
78
+
79
+ Working directory: {{runtime.workingDir}}
80
+ Environment: {{runtime.environment}}
81
+
82
+ ## Task Guidance
83
+
84
+ - Use tools when needed
85
+ - Explain your reasoning clearly
86
+ - Ask clarifying questions when requirements are ambiguous
87
+ - Never claim a file/tool change unless the corresponding tool call actually succeeded
88
+ `;
89
+ };
package/src/index.ts CHANGED
@@ -2,6 +2,7 @@ export * from "./agent-parser.js";
2
2
  export * from "./agent-identity.js";
3
3
  export * from "./compaction.js";
4
4
  export * from "./config.js";
5
+ export * from "./default-agent.js";
5
6
  export * from "./default-tools.js";
6
7
  export * from "./harness.js";
7
8
  export * from "./memory.js";
@@ -572,11 +572,16 @@ export abstract class SqlStorageEngine implements StorageEngine {
572
572
  const pattern = `%${query}%`;
573
573
  // SQLite uses positional ? so we can't reuse $2, need separate params
574
574
  const params: unknown[] = [this.agentId, pattern, pattern];
575
+ // Postgres rejects `jsonb LIKE text` — cast `data` to text in
576
+ // Postgres so the LIKE applies to its JSON serialization. SQLite's
577
+ // `data` column is TEXT (raw JSON string) so no cast needed.
578
+ const dataMatch =
579
+ this.dialect.tag === "postgresql" ? "data::text LIKE $3" : "data LIKE $3";
575
580
  let sql = `SELECT id, title, updated_at, created_at, owner_id, tenant_id,
576
581
  message_count, parent_conversation_id, parent_message_id,
577
582
  has_pending_approvals, channel_meta
578
583
  FROM conversations
579
- WHERE agent_id = $1 AND (title LIKE $2 OR data LIKE $3)`;
584
+ WHERE agent_id = $1 AND (title LIKE $2 OR ${dataMatch})`;
580
585
  if (filterTenant) {
581
586
  sql += ` AND tenant_id = $4`;
582
587
  params.push(tid);