@agentuity/opencode 0.1.42 → 0.1.44

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.
Files changed (122) hide show
  1. package/README.md +9 -9
  2. package/dist/agents/architect.d.ts +1 -1
  3. package/dist/agents/architect.d.ts.map +1 -1
  4. package/dist/agents/architect.js +4 -0
  5. package/dist/agents/architect.js.map +1 -1
  6. package/dist/agents/builder.d.ts +1 -1
  7. package/dist/agents/builder.d.ts.map +1 -1
  8. package/dist/agents/builder.js +4 -0
  9. package/dist/agents/builder.js.map +1 -1
  10. package/dist/agents/expert.d.ts +1 -1
  11. package/dist/agents/expert.d.ts.map +1 -1
  12. package/dist/agents/expert.js +2 -2
  13. package/dist/agents/index.d.ts.map +1 -1
  14. package/dist/agents/index.js +4 -0
  15. package/dist/agents/index.js.map +1 -1
  16. package/dist/agents/lead.d.ts +1 -1
  17. package/dist/agents/lead.d.ts.map +1 -1
  18. package/dist/agents/lead.js +94 -11
  19. package/dist/agents/lead.js.map +1 -1
  20. package/dist/agents/memory/entities.d.ts +32 -0
  21. package/dist/agents/memory/entities.d.ts.map +1 -0
  22. package/dist/agents/memory/entities.js +168 -0
  23. package/dist/agents/memory/entities.js.map +1 -0
  24. package/dist/agents/memory/index.d.ts +4 -0
  25. package/dist/agents/memory/index.d.ts.map +1 -0
  26. package/dist/agents/memory/index.js +2 -0
  27. package/dist/agents/memory/index.js.map +1 -0
  28. package/dist/agents/memory/types.d.ts +71 -0
  29. package/dist/agents/memory/types.d.ts.map +1 -0
  30. package/dist/agents/memory/types.js +2 -0
  31. package/dist/agents/memory/types.js.map +1 -0
  32. package/dist/agents/memory.d.ts +1 -1
  33. package/dist/agents/memory.d.ts.map +1 -1
  34. package/dist/agents/memory.js +344 -7
  35. package/dist/agents/memory.js.map +1 -1
  36. package/dist/agents/product.d.ts +4 -0
  37. package/dist/agents/product.d.ts.map +1 -0
  38. package/dist/agents/product.js +333 -0
  39. package/dist/agents/product.js.map +1 -0
  40. package/dist/agents/reasoner.d.ts +16 -0
  41. package/dist/agents/reasoner.d.ts.map +1 -0
  42. package/dist/agents/reasoner.js +160 -0
  43. package/dist/agents/reasoner.js.map +1 -0
  44. package/dist/agents/reviewer.d.ts +1 -1
  45. package/dist/agents/reviewer.d.ts.map +1 -1
  46. package/dist/agents/reviewer.js +9 -0
  47. package/dist/agents/reviewer.js.map +1 -1
  48. package/dist/background/manager.d.ts +1 -0
  49. package/dist/background/manager.d.ts.map +1 -1
  50. package/dist/background/manager.js +7 -1
  51. package/dist/background/manager.js.map +1 -1
  52. package/dist/plugin/hooks/index.d.ts +2 -0
  53. package/dist/plugin/hooks/index.d.ts.map +1 -0
  54. package/dist/plugin/hooks/index.js +2 -0
  55. package/dist/plugin/hooks/index.js.map +1 -0
  56. package/dist/plugin/hooks/session-memory.d.ts.map +1 -1
  57. package/dist/plugin/hooks/session-memory.js +5 -0
  58. package/dist/plugin/hooks/session-memory.js.map +1 -1
  59. package/dist/plugin/hooks/tools.d.ts +11 -0
  60. package/dist/plugin/hooks/tools.d.ts.map +1 -1
  61. package/dist/plugin/hooks/tools.js +18 -1
  62. package/dist/plugin/hooks/tools.js.map +1 -1
  63. package/dist/plugin/plugin.d.ts.map +1 -1
  64. package/dist/plugin/plugin.js +203 -12
  65. package/dist/plugin/plugin.js.map +1 -1
  66. package/dist/tmux/executor.d.ts +43 -20
  67. package/dist/tmux/executor.d.ts.map +1 -1
  68. package/dist/tmux/executor.js +547 -243
  69. package/dist/tmux/executor.js.map +1 -1
  70. package/dist/tmux/index.d.ts +1 -1
  71. package/dist/tmux/index.d.ts.map +1 -1
  72. package/dist/tmux/index.js +1 -1
  73. package/dist/tmux/index.js.map +1 -1
  74. package/dist/tmux/manager.d.ts +37 -3
  75. package/dist/tmux/manager.d.ts.map +1 -1
  76. package/dist/tmux/manager.js +219 -96
  77. package/dist/tmux/manager.js.map +1 -1
  78. package/dist/tmux/types.d.ts +10 -0
  79. package/dist/tmux/types.d.ts.map +1 -1
  80. package/dist/tmux/types.js.map +1 -1
  81. package/dist/tmux/utils.d.ts +17 -0
  82. package/dist/tmux/utils.d.ts.map +1 -1
  83. package/dist/tmux/utils.js +39 -0
  84. package/dist/tmux/utils.js.map +1 -1
  85. package/dist/tools/background.d.ts +2 -0
  86. package/dist/tools/background.d.ts.map +1 -1
  87. package/dist/tools/background.js +3 -3
  88. package/dist/tools/background.js.map +1 -1
  89. package/dist/tools/delegate.d.ts +4 -0
  90. package/dist/tools/delegate.d.ts.map +1 -1
  91. package/dist/tools/delegate.js +18 -3
  92. package/dist/tools/delegate.js.map +1 -1
  93. package/dist/types.d.ts +2 -0
  94. package/dist/types.d.ts.map +1 -1
  95. package/dist/types.js +2 -0
  96. package/dist/types.js.map +1 -1
  97. package/package.json +3 -3
  98. package/src/agents/architect.ts +4 -0
  99. package/src/agents/builder.ts +4 -0
  100. package/src/agents/expert.ts +2 -2
  101. package/src/agents/index.ts +4 -0
  102. package/src/agents/lead.ts +94 -11
  103. package/src/agents/memory/entities.ts +220 -0
  104. package/src/agents/memory/index.ts +22 -0
  105. package/src/agents/memory/types.ts +76 -0
  106. package/src/agents/memory.ts +344 -7
  107. package/src/agents/product.ts +336 -0
  108. package/src/agents/reasoner.ts +182 -0
  109. package/src/agents/reviewer.ts +9 -0
  110. package/src/background/manager.ts +7 -1
  111. package/src/plugin/hooks/index.ts +1 -0
  112. package/src/plugin/hooks/session-memory.ts +5 -0
  113. package/src/plugin/hooks/tools.ts +24 -1
  114. package/src/plugin/plugin.ts +228 -12
  115. package/src/tmux/executor.ts +610 -249
  116. package/src/tmux/index.ts +5 -2
  117. package/src/tmux/manager.ts +241 -98
  118. package/src/tmux/types.ts +11 -0
  119. package/src/tmux/utils.ts +39 -0
  120. package/src/tools/background.ts +3 -3
  121. package/src/tools/delegate.ts +18 -3
  122. package/src/types.ts +2 -0
@@ -1,11 +1,12 @@
1
1
  import type { PluginInput, Hooks } from '@opencode-ai/plugin';
2
2
  import { tool } from '@opencode-ai/plugin';
3
+ import { StructuredError } from '@agentuity/core';
3
4
  import type { AgentConfig, CommandDefinition } from '../types';
4
5
  import { loadAllSkills, type LoadedSkill } from '../skills';
5
6
  import { agents } from '../agents';
6
7
  import { loadCoderConfig, getDefaultConfig, mergeConfig, validateAndWarnConfigs } from '../config';
7
8
  import { createSessionHooks } from './hooks/session';
8
- import { createToolHooks } from './hooks/tools';
9
+ import { createToolHooks, getCoderProfile } from './hooks/tools';
9
10
  import { createKeywordHooks } from './hooks/keyword';
10
11
  import { createParamsHooks } from './hooks/params';
11
12
  import { createCadenceHooks } from './hooks/cadence';
@@ -13,6 +14,26 @@ import { createSessionMemoryHooks } from './hooks/session-memory';
13
14
  import type { AgentRole } from '../types';
14
15
  import { BackgroundManager } from '../background';
15
16
  import { TmuxSessionManager } from '../tmux';
17
+ import { checkAuth } from '../services/auth';
18
+
19
+ // ─────────────────────────────────────────────────────────────────────────────
20
+ // Memory Share Tool Errors
21
+ // ─────────────────────────────────────────────────────────────────────────────
22
+
23
+ const MemoryShareAuthError = StructuredError(
24
+ 'MemoryShareAuthError',
25
+ 'Authentication required to share memory content'
26
+ )<{ reason: string }>();
27
+
28
+ const MemoryShareCLIError = StructuredError(
29
+ 'MemoryShareCLIError',
30
+ 'CLI command failed to create stream'
31
+ )<{ exitCode: number; stderr: string }>();
32
+
33
+ const MemoryShareError = StructuredError(
34
+ 'MemoryShareError',
35
+ 'Failed to create public memory share'
36
+ )<{ reason: string }>();
16
37
 
17
38
  // Sandbox environment detection
18
39
  const SANDBOX_ID = process.env.AGENTUITY_SANDBOX_ID;
@@ -53,6 +74,8 @@ const AGENT_MENTIONS: Record<AgentRole, string> = {
53
74
  expert: '@Agentuity Coder Expert',
54
75
  planner: '@Agentuity Coder Planner',
55
76
  runner: '@Agentuity Coder Runner',
77
+ reasoner: '@Agentuity Coder Reasoner',
78
+ product: '@Agentuity Coder Product',
56
79
  };
57
80
 
58
81
  export async function createCoderPlugin(ctx: PluginInput): Promise<Hooks> {
@@ -95,6 +118,11 @@ export async function createCoderPlugin(ctx: PluginInput): Promise<Hooks> {
95
118
  void tmuxManager.onSessionDeleted(event);
96
119
  }
97
120
  : undefined,
121
+ onShutdown: tmuxManager
122
+ ? () => {
123
+ void tmuxManager.cleanup();
124
+ }
125
+ : undefined,
98
126
  });
99
127
 
100
128
  // Session memory hooks handle checkpointing and compaction for non-Cadence sessions
@@ -273,21 +301,24 @@ You are the Agentuity Coder Lead agent orchestrating the Agentuity Coder team.
273
301
  - **@Agentuity Coder Architect**: Complex autonomous tasks, Cadence mode (GPT Codex)
274
302
  - **@Agentuity Coder Reviewer**: Review changes, catch issues, apply fixes
275
303
  - **@Agentuity Coder Memory**: Store context, remember decisions
304
+ - **@Agentuity Coder Reasoner**: Extract structured conclusions, resolve conflicts, surface corrections
276
305
  - **@Agentuity Coder Expert**: Agentuity CLI and cloud services specialist
277
306
  - **@Agentuity Coder Planner**: Deep planning for complex architecture decisions
278
307
  - **@Agentuity Coder Runner**: Run lint/build/test commands, returns structured results
308
+ - **@Agentuity Coder Product**: Clarify requirements, validate features, track progress
279
309
 
280
310
  ## Task
281
311
  $ARGUMENTS
282
312
 
283
313
  ## Guidelines
284
314
  1. Use @Agentuity Coder Scout first to understand context
285
- 2. Delegate implementation to @Agentuity Coder Builder (or Architect for complex work)
286
- 3. Delegate lint/build/test commands to @Agentuity Coder Runner for structured results
287
- 4. Have @Agentuity Coder Reviewer check the work
288
- 5. Use @Agentuity Coder Expert for Agentuity CLI questions
289
- 6. Only use cloud services when genuinely helpful
290
- 7. **When done, tell @Agentuity Coder Memory to memorialize the session**
315
+ 2. Use @Agentuity Coder Product to clarify requirements if unclear
316
+ 3. Delegate implementation to @Agentuity Coder Builder (or Architect for complex work)
317
+ 4. Delegate lint/build/test commands to @Agentuity Coder Runner for structured results
318
+ 5. Have @Agentuity Coder Reviewer check the work
319
+ 6. Use @Agentuity Coder Expert for Agentuity CLI questions
320
+ 7. Only use cloud services when genuinely helpful
321
+ 8. **When done, tell @Agentuity Coder Memory to memorialize the session**
291
322
  </coder-mode>`,
292
323
  agent: 'Agentuity Coder Lead',
293
324
  argumentHint: '"task description"',
@@ -311,6 +342,46 @@ $ARGUMENTS`,
311
342
  argumentHint: '(optional additional context)',
312
343
  },
313
344
 
345
+ 'agentuity-memory-share': {
346
+ name: 'agentuity-memory-share',
347
+ description: '🔗 Share memory content publicly with a shareable URL',
348
+ template: `Create a public shareable link for memory content.
349
+
350
+ The user wants to share: $ARGUMENTS
351
+
352
+ ## Your Task
353
+
354
+ 1. **Understand what to share** — Based on the user's request, determine what content to share:
355
+ - A summary of the current session
356
+ - The latest compaction
357
+ - Specific decisions or corrections
358
+ - A custom selection of context
359
+ - If the request implies context not in the current chat, pull from memory stores (KV/Vector)
360
+
361
+ 2. **Prepare the content** — Format the content appropriately:
362
+ - Use clear markdown formatting
363
+ - Include relevant context (what this is, when it was created)
364
+ - Be conservative with sensitive information (no secrets, credentials, etc.)
365
+ - Keep it focused and useful for the recipient
366
+
367
+ 3. **Share it** — Call the \`agentuity_memory_share\` tool with:
368
+ - \`content\`: The formatted content to share
369
+ - \`ttl_seconds\`: Only if the user specified a duration (otherwise use default 30-day expiration)
370
+ - \`metadata\`: Optional tags like \`type=summary\` or \`source=session\`
371
+ - \`content_type\`: Usually \`text/markdown\` (default)
372
+
373
+ 4. **Return the URL** — Give the user the public URL they can share anywhere.
374
+
375
+ ## Guidelines
376
+ - The URL works without authentication — anyone with the link can view it
377
+ - Content is stored in Agentuity Cloud Streams with automatic expiration
378
+ - Don't include secrets, API keys, or sensitive credentials in shared content
379
+ - If unsure what to share, ask the user for clarification`,
380
+ agent: 'Agentuity Coder Memory',
381
+ argumentHint:
382
+ '"share a summary of this session" or "share the auth decisions with 1 hour TTL"',
383
+ },
384
+
314
385
  // ─────────────────────────────────────────────────────────────────────
315
386
  // Agentuity Cloud Service Commands
316
387
  // ─────────────────────────────────────────────────────────────────────
@@ -409,9 +480,11 @@ You are the Agentuity Coder Lead in **Cadence mode** — a long-running autonomo
409
480
  - **@Agentuity Coder Builder**: Quick fixes, simple changes (for minor iterations only)
410
481
  - **@Agentuity Coder Reviewer**: Review changes, catch issues, apply fixes
411
482
  - **@Agentuity Coder Memory**: Store context, remember decisions, checkpoints
483
+ - **@Agentuity Coder Reasoner**: Extract structured conclusions, resolve conflicts, surface corrections
412
484
  - **@Agentuity Coder Expert**: Agentuity CLI and cloud services specialist
413
485
  - **@Agentuity Coder Planner**: Deep planning for complex architecture decisions
414
486
  - **@Agentuity Coder Runner**: Run lint/build/test commands, returns structured results
487
+ - **@Agentuity Coder Product**: Clarify requirements, validate features, track progress, Cadence briefings
415
488
 
416
489
  ## Task
417
490
  $ARGUMENTS
@@ -498,8 +571,10 @@ Use this to:
498
571
  - Architect: Complex autonomous tasks, Cadence mode, deep reasoning (GPT Codex)
499
572
  - Reviewer: Review changes, catch issues, apply fixes
500
573
  - Memory: Store context, remember decisions across sessions
574
+ - Reasoner: Extract structured conclusions, resolve conflicts, surface corrections
501
575
  - Expert: Get help with Agentuity CLI and cloud services
502
- - Planner: Strategic advisor for complex architecture and deep planning (read-only)`,
576
+ - Planner: Strategic advisor for complex architecture and deep planning (read-only)
577
+ - Runner: Execute lint/build/test/typecheck/format commands, returns structured results`,
503
578
  args: {
504
579
  agent: s
505
580
  .enum([
@@ -508,6 +583,7 @@ Use this to:
508
583
  'architect',
509
584
  'reviewer',
510
585
  'memory',
586
+ 'reasoner',
511
587
  'expert',
512
588
  'planner',
513
589
  'runner',
@@ -542,9 +618,11 @@ IMPORTANT: Use this tool instead of the 'task' tool when:
542
618
  'architect',
543
619
  'reviewer',
544
620
  'memory',
621
+ 'reasoner',
545
622
  'expert',
546
623
  'planner',
547
624
  'runner',
625
+ 'product',
548
626
  ])
549
627
  .describe('Agent role to run the task'),
550
628
  task: s.string().describe('Task prompt to run in the background'),
@@ -617,11 +695,149 @@ IMPORTANT: Use this tool instead of the 'task' tool when:
617
695
  },
618
696
  });
619
697
 
698
+ const memoryShare = tool({
699
+ description: `Share memory content publicly via Agentuity Cloud Streams.
700
+
701
+ Creates a public URL that can be shared with anyone - no authentication required to access.
702
+ The content is stored in Agentuity's durable stream storage with optional TTL.
703
+
704
+ Use this when:
705
+ - User wants to share context with another agent/session
706
+ - User wants to export a summary, compaction, or session for external use
707
+ - User explicitly asks to "share" or "make public" some memory content
708
+
709
+ Returns the public URL that can be copied and used anywhere.`,
710
+ args: {
711
+ content: s.string().describe('The content to share publicly'),
712
+ namespace: s
713
+ .string()
714
+ .optional()
715
+ .describe('Stream namespace (default: agentuity-opencode-shares)'),
716
+ ttl_seconds: s
717
+ .number()
718
+ .optional()
719
+ .describe('TTL in seconds (60-7776000, or omit for 30-day default)'),
720
+ content_type: s.string().optional().describe('Content type (default: text/markdown)'),
721
+ metadata: s
722
+ .record(s.string(), s.string())
723
+ .optional()
724
+ .describe('Optional metadata key-value pairs'),
725
+ compress: s.boolean().optional().describe('Enable gzip compression'),
726
+ region: s.string().optional().describe('Cloud region (use, usc, usw). Default: usc'),
727
+ },
728
+ async execute(args) {
729
+ // Get the profile first - this ensures checkAuth() and CLI use the same profile
730
+ const profile = getCoderProfile();
731
+ const originalProfile = process.env.AGENTUITY_PROFILE;
732
+
733
+ try {
734
+ // Set profile before auth check so checkAuth reads the correct config
735
+ process.env.AGENTUITY_PROFILE = profile;
736
+
737
+ // Check auth first
738
+ const authResult = await checkAuth();
739
+ if (!authResult.ok) {
740
+ const err = new MemoryShareAuthError({ reason: authResult.error });
741
+ return JSON.stringify({
742
+ success: false,
743
+ error: err.message,
744
+ errorTag: err._tag,
745
+ details: { reason: authResult.error },
746
+ });
747
+ }
748
+
749
+ // Build CLI command
750
+ const namespace = args.namespace ?? 'agentuity-opencode-shares';
751
+ const contentType = args.content_type ?? 'text/markdown';
752
+
753
+ const cliArgs = ['agentuity', '--json', 'cloud', 'stream', 'create', namespace, '-'];
754
+ cliArgs.push('--content-type', contentType);
755
+ cliArgs.push('--region', args.region ?? 'usc');
756
+
757
+ if (args.ttl_seconds !== undefined) {
758
+ cliArgs.push('--ttl', String(args.ttl_seconds));
759
+ }
760
+
761
+ if (args.compress) {
762
+ cliArgs.push('--compress');
763
+ }
764
+
765
+ if (args.metadata && Object.keys(args.metadata).length > 0) {
766
+ const metadataStr = Object.entries(args.metadata)
767
+ .map(([k, v]) => `${k}=${v}`)
768
+ .join(',');
769
+ cliArgs.push('--metadata', metadataStr);
770
+ }
771
+ const proc = Bun.spawn(cliArgs, {
772
+ stdin: 'pipe',
773
+ stdout: 'pipe',
774
+ stderr: 'pipe',
775
+ env: {
776
+ ...process.env,
777
+ AGENTUITY_PROFILE: profile,
778
+ },
779
+ });
780
+
781
+ // Write content to stdin (Bun's FileSink API)
782
+ proc.stdin.write(new TextEncoder().encode(args.content));
783
+ proc.stdin.end();
784
+
785
+ const [stdout, stderr, exitCode] = await Promise.all([
786
+ new Response(proc.stdout).text(),
787
+ new Response(proc.stderr).text(),
788
+ proc.exited,
789
+ ]);
790
+
791
+ if (exitCode !== 0) {
792
+ const err = new MemoryShareCLIError({
793
+ exitCode,
794
+ stderr: stderr || `CLI exited with code ${exitCode}`,
795
+ });
796
+ return JSON.stringify({
797
+ success: false,
798
+ error: err.message,
799
+ errorTag: err._tag,
800
+ details: { exitCode, stderr },
801
+ });
802
+ }
803
+
804
+ // Parse JSON response from CLI
805
+ const result = JSON.parse(stdout);
806
+
807
+ return JSON.stringify({
808
+ success: true,
809
+ url: result.url,
810
+ id: result.id,
811
+ namespace: result.namespace,
812
+ sizeBytes: result.sizeBytes,
813
+ expiresAt: result.expiresAt,
814
+ });
815
+ } catch (error) {
816
+ const reason = error instanceof Error ? error.message : 'Failed to create stream';
817
+ const err = new MemoryShareError({ reason });
818
+ return JSON.stringify({
819
+ success: false,
820
+ error: err.message,
821
+ errorTag: err._tag,
822
+ details: { reason },
823
+ });
824
+ } finally {
825
+ // Restore original profile
826
+ if (originalProfile !== undefined) {
827
+ process.env.AGENTUITY_PROFILE = originalProfile;
828
+ } else {
829
+ delete process.env.AGENTUITY_PROFILE;
830
+ }
831
+ }
832
+ },
833
+ });
834
+
620
835
  return {
621
- coder_delegate: coderDelegate,
622
- background_task: backgroundTask,
623
- background_output: backgroundOutput,
624
- background_cancel: backgroundCancel,
836
+ agentuity_coder_delegate: coderDelegate,
837
+ agentuity_background_task: backgroundTask,
838
+ agentuity_background_output: backgroundOutput,
839
+ agentuity_background_cancel: backgroundCancel,
840
+ agentuity_memory_share: memoryShare,
625
841
  };
626
842
  }
627
843