@labelbox/recursion-sdk 0.0.165 → 0.0.166

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.
@@ -58,8 +58,12 @@ export declare const DOMAINS: readonly [{
58
58
  readonly id: "integrations";
59
59
  readonly title: "Integrations";
60
60
  readonly order: 13;
61
+ }, {
62
+ readonly id: "managed-agents";
63
+ readonly title: "Managed Agents";
64
+ readonly order: 14;
61
65
  }];
62
- /** Union of the thirteen canonical domain ids. */
66
+ /** Union of the fourteen canonical domain ids. */
63
67
  export type DomainId = (typeof DOMAINS)[number]['id'];
64
68
  /** Runtime guard: is `value` one of the canonical domain ids? */
65
69
  export declare function isDomainId(value: unknown): value is DomainId;
@@ -1,6 +1,6 @@
1
1
  // Canonical **product-domain taxonomy** — the single source of truth for the
2
2
  // docs information architecture. The How-to (recipes) and Explanation (concepts)
3
- // quadrants group their entries under these thirteen flat domains; Reference keeps
3
+ // quadrants group their entries under these fourteen flat domains; Reference keeps
4
4
  // its own deep, spec-derived tree (it is not domain-grouped).
5
5
  //
6
6
  // Consumed by the frontend docs nav, the `rl` CLI, and the dx generators. The
@@ -24,6 +24,7 @@ export const DOMAINS = [
24
24
  { id: 'cost', title: 'Cost', order: 11 },
25
25
  { id: 'administration', title: 'Administration', order: 12 },
26
26
  { id: 'integrations', title: 'Integrations', order: 13 },
27
+ { id: 'managed-agents', title: 'Managed Agents', order: 14 },
27
28
  ];
28
29
  const DOMAIN_IDS = new Set(DOMAINS.map((d) => d.id));
29
30
  /** Runtime guard: is `value` one of the canonical domain ids? */
@@ -4661,6 +4661,140 @@ export const RECIPE_REFERENCE = {
4661
4661
  ],
4662
4662
  },
4663
4663
  },
4664
+ 'define-a-session-outcome': {
4665
+ id: 'define-a-session-outcome',
4666
+ title: 'Define a session outcome',
4667
+ goal: 'Give a session a rubric so the agent is graded against a checkable bar, then read the verdict it earned.',
4668
+ category: 'managed-agents',
4669
+ video: 'define-a-session-outcome.mp4',
4670
+ walkthrough: [
4671
+ {
4672
+ caption: 'Start a session with an outcome',
4673
+ image: '01-start-a-session-with-an-outcome.png',
4674
+ description: 'The rubric travels with the start request: the session is graded against it from the first turn.',
4675
+ },
4676
+ {
4677
+ caption: 'Wait for the graded session, then read the verdict',
4678
+ image: '02-wait-for-the-graded-session-then-read-the-verdict.png',
4679
+ description: 'A graded session ends once the grader has run its revision passes, and the outcome then carries its evaluations: a per-criterion verdict with rationale.',
4680
+ },
4681
+ ],
4682
+ steps: [
4683
+ {
4684
+ kind: 'sdk',
4685
+ operationId: 'managedAgentsCreateEnvironment',
4686
+ caption: 'Create the environment the agent works in',
4687
+ phase: 'setup',
4688
+ inputs: {
4689
+ name: {
4690
+ value: 'Graded sandbox',
4691
+ },
4692
+ provider: {
4693
+ value: 'runs',
4694
+ },
4695
+ },
4696
+ captures: {
4697
+ environmentId: 'environment_id',
4698
+ },
4699
+ },
4700
+ {
4701
+ kind: 'sdk',
4702
+ operationId: 'managedAgentsCreateAgent',
4703
+ caption: 'Create the agent',
4704
+ phase: 'setup',
4705
+ inputs: {
4706
+ name: {
4707
+ value: 'Report writer',
4708
+ },
4709
+ system: {
4710
+ value: 'Write the requested report. Follow every instruction exactly.',
4711
+ },
4712
+ model: {
4713
+ value: '<gatewayModel>',
4714
+ },
4715
+ },
4716
+ captures: {
4717
+ agentId: 'agent_id',
4718
+ },
4719
+ },
4720
+ {
4721
+ kind: 'sdk',
4722
+ operationId: 'managedAgentsStartSession',
4723
+ caption: 'Start a session with an outcome',
4724
+ phase: 'main',
4725
+ inputs: {
4726
+ agent_id: {
4727
+ $ref: 'agentId',
4728
+ },
4729
+ environment_id: {
4730
+ $ref: 'environmentId',
4731
+ },
4732
+ message: {
4733
+ value: 'Write a two-sentence summary of what a managed agent session is.',
4734
+ },
4735
+ outcome: {
4736
+ value: {
4737
+ description: 'A two-sentence summary of what a managed agent session is.',
4738
+ rubric: '- The summary is exactly two sentences.\n- The summary names the sandbox the session runs in.',
4739
+ max_iterations: 3,
4740
+ },
4741
+ },
4742
+ },
4743
+ captures: {
4744
+ sessionId: 'session_id',
4745
+ },
4746
+ },
4747
+ {
4748
+ kind: 'sdk',
4749
+ operationId: 'managedAgentsGetSession',
4750
+ caption: 'Wait for the graded session to finish',
4751
+ phase: 'main',
4752
+ inputs: {
4753
+ session_id: {
4754
+ $ref: 'sessionId',
4755
+ },
4756
+ },
4757
+ captures: {
4758
+ sessionStatus: 'status',
4759
+ },
4760
+ },
4761
+ {
4762
+ kind: 'sdk',
4763
+ operationId: 'managedAgentsListSessionOutcomes',
4764
+ caption: 'Read the verdict',
4765
+ phase: 'main',
4766
+ inputs: {
4767
+ session_id: {
4768
+ $ref: 'sessionId',
4769
+ },
4770
+ },
4771
+ captures: {
4772
+ outcomes: 'outcomes',
4773
+ },
4774
+ },
4775
+ ],
4776
+ sdk: {
4777
+ setup: "// Create the environment the agent works in\nconst managedAgent = await rl.managedAgents.createEnvironment({\n body: {\n name: 'Graded sandbox',\n provider: 'runs',\n },\n});\nconst environmentId = managedAgent.environment_id;\n\n// Create the agent\nconst managedAgent2 = await rl.managedAgents.createAgent({\n body: {\n model: '<gatewayModel>',\n name: 'Report writer',\n system: 'Write the requested report. Follow every instruction exactly.',\n },\n});\nconst agentId = managedAgent2.agent_id;",
4778
+ main: "// Start a session with an outcome\nconst managedAgent3 = await rl.managedAgents.startSession({\n body: {\n agent_id: agentId,\n environment_id: environmentId,\n message: 'Write a two-sentence summary of what a managed agent session is.',\n outcome: { description: 'A two-sentence summary of what a managed agent session is.', rubric: '- The summary is exactly two sentences.\\n- The summary names the sandbox the session runs in.', max_iterations: 3 },\n },\n});\nconst sessionId = managedAgent3.session_id;\n\n// Wait for the graded session to finish\nlet managedAgent4;\nconst managedAgent4Deadline = Date.now() + 900000;\nfor (;;) {\n managedAgent4 = await rl.managedAgents.getSession({\n session_id: sessionId,\n });\n if (['failed', 'cancelled'].includes(managedAgent4.status)) throw new Error('reached a terminal failure state: ' + managedAgent4.status);\n if (['completed'].includes(managedAgent4.status)) break;\n if (Date.now() > managedAgent4Deadline) throw new Error('timed out after 900000ms waiting for a terminal state');\n await new Promise((resolve) => setTimeout(resolve, 10000));\n}\nconst sessionStatus = managedAgent4.status;\n\n// Read the verdict\nconst managedAgent5 = await rl.managedAgents.listSessionOutcomes({\n session_id: sessionId,\n});\nconst outcomes = managedAgent5.outcomes;",
4779
+ },
4780
+ cli: {
4781
+ setup: '# Create the environment the agent works in\nENVIRONMENT_ID=$(rl managed-agents create-environment \\\n --data "{ \\"name\\": \\"Graded sandbox\\", \\"provider\\": \\"runs\\" }" \\\n | jq -r \'.environment_id\')\n\n# Create the agent\nAGENT_ID=$(rl managed-agents create-agent \\\n --data "{ \\"model\\": \\"<gatewayModel>\\", \\"name\\": \\"Report writer\\", \\"system\\": \\"Write the requested report. Follow every instruction exactly.\\" }" \\\n | jq -r \'.agent_id\')',
4782
+ main: '# Start a session with an outcome\nSESSION_ID=$(rl managed-agents start-session \\\n --data "{ \\"agent_id\\": \\"$AGENT_ID\\", \\"environment_id\\": \\"$ENVIRONMENT_ID\\", \\"message\\": \\"Write a two-sentence summary of what a managed agent session is.\\", \\"outcome\\": { \\"description\\": \\"A two-sentence summary of what a managed agent session is.\\", \\"rubric\\": \\"- The summary is exactly two sentences.\\\\n- The summary names the sandbox the session runs in.\\", \\"max_iterations\\": 3 } }" \\\n | jq -r \'.session_id\')\n\n# Wait for the graded session to finish\ndeadline=$(( $(date +%s) + 900 ))\nwhile :; do\n response=$(rl managed-agents get-session \\\n --session_id "$SESSION_ID")\n case "$(printf \'%s\' "$response" | jq -r \'.status\')" in failed|cancelled) echo "reached a terminal failure state: $response" >&2; exit 1 ;; esac\n case "$(printf \'%s\' "$response" | jq -r \'.status\')" in completed) break ;; esac\n [ "$(date +%s)" -ge "$deadline" ] && { echo "timed out waiting for a terminal state" >&2; exit 1; }\n sleep 10\ndone\nSESSION_STATUS=$(printf \'%s\' "$response" | jq -r \'.status\')\n\n# Read the verdict\nOUTCOMES=$(rl managed-agents list-session-outcomes \\\n --session_id "$SESSION_ID" \\\n | jq -r \'.outcomes\')',
4783
+ },
4784
+ curl: {
4785
+ setup: '# Create the environment the agent works in\nENVIRONMENT_ID=$(curl -s -X POST "https://api.recursion.labelbox.com/managed-agents/v1/environments" \\\n -H "Authorization: Bearer $LABELBOX_API_KEY" \\\n -H "Content-Type: application/json" \\\n -d "{ \\"name\\": \\"Graded sandbox\\", \\"provider\\": \\"runs\\" }" \\\n | jq -r \'.environment_id\')\n\n# Create the agent\nAGENT_ID=$(curl -s -X POST "https://api.recursion.labelbox.com/managed-agents/v1/agents" \\\n -H "Authorization: Bearer $LABELBOX_API_KEY" \\\n -H "Content-Type: application/json" \\\n -d "{ \\"model\\": \\"<gatewayModel>\\", \\"name\\": \\"Report writer\\", \\"system\\": \\"Write the requested report. Follow every instruction exactly.\\" }" \\\n | jq -r \'.agent_id\')',
4786
+ main: '# Start a session with an outcome\nSESSION_ID=$(curl -s -X POST "https://api.recursion.labelbox.com/managed-agents/v1/sessions" \\\n -H "Authorization: Bearer $LABELBOX_API_KEY" \\\n -H "Content-Type: application/json" \\\n -d "{ \\"agent_id\\": \\"$AGENT_ID\\", \\"environment_id\\": \\"$ENVIRONMENT_ID\\", \\"message\\": \\"Write a two-sentence summary of what a managed agent session is.\\", \\"outcome\\": { \\"description\\": \\"A two-sentence summary of what a managed agent session is.\\", \\"rubric\\": \\"- The summary is exactly two sentences.\\\\n- The summary names the sandbox the session runs in.\\", \\"max_iterations\\": 3 } }" \\\n | jq -r \'.session_id\')\n\n# Wait for the graded session to finish\ndeadline=$(( $(date +%s) + 900 ))\nwhile :; do\n response=$(curl -s -X GET "https://api.recursion.labelbox.com/managed-agents/v1/sessions/$SESSION_ID" \\\n -H "Authorization: Bearer $LABELBOX_API_KEY")\n case "$(printf \'%s\' "$response" | jq -r \'.status\')" in failed|cancelled) echo "reached a terminal failure state: $response" >&2; exit 1 ;; esac\n case "$(printf \'%s\' "$response" | jq -r \'.status\')" in completed) break ;; esac\n [ "$(date +%s)" -ge "$deadline" ] && { echo "timed out waiting for a terminal state" >&2; exit 1; }\n sleep 10\ndone\nSESSION_STATUS=$(printf \'%s\' "$response" | jq -r \'.status\')\n\n# Read the verdict\nOUTCOMES=$(curl -s -X GET "https://api.recursion.labelbox.com/managed-agents/v1/sessions/$SESSION_ID/outcomes" \\\n -H "Authorization: Bearer $LABELBOX_API_KEY" \\\n | jq -r \'.outcomes\')',
4787
+ },
4788
+ related: {
4789
+ variationOf: 'run-an-agent-session',
4790
+ learnMore: [
4791
+ {
4792
+ type: 'concept',
4793
+ id: 'how-grading-works',
4794
+ },
4795
+ ],
4796
+ },
4797
+ },
4664
4798
  'delete-a-draft-version': {
4665
4799
  id: 'delete-a-draft-version',
4666
4800
  title: 'Delete a draft version',
@@ -6288,6 +6422,136 @@ export const RECIPE_REFERENCE = {
6288
6422
  ],
6289
6423
  },
6290
6424
  },
6425
+ 'give-an-agent-a-skill': {
6426
+ id: 'give-an-agent-a-skill',
6427
+ title: 'Give an agent a skill',
6428
+ goal: 'Write a procedure as an Agent Skill and attach it to an agent, so every session it starts loads that procedure.',
6429
+ category: 'managed-agents',
6430
+ video: 'give-an-agent-a-skill.mp4',
6431
+ walkthrough: [
6432
+ {
6433
+ caption: 'Write the skill document',
6434
+ image: '01-write-the-skill-document.png',
6435
+ description: 'A skill is a SKILL.md: YAML frontmatter naming and describing it, then the procedure itself.',
6436
+ },
6437
+ {
6438
+ caption: 'Attach the skill to the agent',
6439
+ image: '02-attach-the-skill-to-the-agent.png',
6440
+ description: 'Attaching by skill id follows the skill: the agent picks up each new version as it is published.',
6441
+ },
6442
+ {
6443
+ caption: 'Confirm the agent carries the skill',
6444
+ image: '03-confirm-the-agent-carries-the-skill.png',
6445
+ description: 'Reading the agent back shows the attachment as the service stored it, on a new agent version.',
6446
+ },
6447
+ ],
6448
+ steps: [
6449
+ {
6450
+ kind: 'sdk',
6451
+ operationId: 'managedAgentsCreateAgent',
6452
+ caption: 'Create the agent the skill is for',
6453
+ phase: 'setup',
6454
+ inputs: {
6455
+ name: {
6456
+ value: 'Release notes writer',
6457
+ },
6458
+ system: {
6459
+ value: 'Follow the attached procedures exactly.',
6460
+ },
6461
+ model: {
6462
+ value: '<gatewayModel>',
6463
+ },
6464
+ },
6465
+ captures: {
6466
+ agentId: 'agent_id',
6467
+ },
6468
+ },
6469
+ {
6470
+ kind: 'sdk',
6471
+ operationId: 'managedAgentsCreateSkill',
6472
+ caption: 'Write the skill document',
6473
+ phase: 'main',
6474
+ inputs: {
6475
+ document: {
6476
+ value: '---\nname: write-release-notes\ndescription: Turn a list of merged changes into release notes grouped by audience impact.\n---\n\n# Write release notes\n\n1. Group the merged changes by who notices them: users, operators, nobody.\n2. Drop the "nobody" group.\n3. Write one line per change, in the reader\'s language, not the commit\'s.',
6477
+ },
6478
+ display_title: {
6479
+ value: 'Write release notes',
6480
+ },
6481
+ },
6482
+ captures: {
6483
+ skillId: 'skill_id',
6484
+ },
6485
+ },
6486
+ {
6487
+ kind: 'sdk',
6488
+ operationId: 'managedAgentsUpdateAgent',
6489
+ caption: 'Attach the skill to the agent',
6490
+ phase: 'main',
6491
+ inputs: {
6492
+ agent_id: {
6493
+ $ref: 'agentId',
6494
+ },
6495
+ skills: {
6496
+ value: [
6497
+ {
6498
+ skill_id: {
6499
+ $ref: 'skillId',
6500
+ },
6501
+ },
6502
+ ],
6503
+ },
6504
+ },
6505
+ captures: {
6506
+ agentVersionId: 'latest_agent_version_id',
6507
+ },
6508
+ },
6509
+ {
6510
+ kind: 'sdk',
6511
+ operationId: 'managedAgentsGetAgent',
6512
+ caption: 'Confirm the agent carries the skill',
6513
+ phase: 'main',
6514
+ inputs: {
6515
+ agent_id: {
6516
+ $ref: 'agentId',
6517
+ },
6518
+ },
6519
+ captures: {
6520
+ attachedSkills: 'skills',
6521
+ },
6522
+ },
6523
+ ],
6524
+ sdk: {
6525
+ setup: "// Create the agent the skill is for\nconst managedAgent = await rl.managedAgents.createAgent({\n body: {\n model: '<gatewayModel>',\n name: 'Release notes writer',\n system: 'Follow the attached procedures exactly.',\n },\n});\nconst agentId = managedAgent.agent_id;",
6526
+ main: "// Write the skill document\nconst managedAgent2 = await rl.managedAgents.createSkill({\n body: {\n display_title: 'Write release notes',\n document: '---\\nname: write-release-notes\\ndescription: Turn a list of merged changes into release notes grouped by audience impact.\\n---\\n\\n# Write release notes\\n\\n1. Group the merged changes by who notices them: users, operators, nobody.\\n2. Drop the \"nobody\" group.\\n3. Write one line per change, in the reader\\'s language, not the commit\\'s.',\n },\n});\nconst skillId = managedAgent2.skill_id;\n\n// Attach the skill to the agent\nconst managedAgent3 = await rl.managedAgents.updateAgent({\n agent_id: agentId,\n body: {\n agent_id: agentId,\n skills: [{ skill_id: skillId }],\n },\n});\nconst agentVersionId = managedAgent3.latest_agent_version_id;\n\n// Confirm the agent carries the skill\nconst managedAgent4 = await rl.managedAgents.getAgent({\n agent_id: agentId,\n});\nconst attachedSkills = managedAgent4.skills;",
6527
+ },
6528
+ cli: {
6529
+ setup: '# Create the agent the skill is for\nAGENT_ID=$(rl managed-agents create-agent \\\n --data "{ \\"model\\": \\"<gatewayModel>\\", \\"name\\": \\"Release notes writer\\", \\"system\\": \\"Follow the attached procedures exactly.\\" }" \\\n | jq -r \'.agent_id\')',
6530
+ main: '# Write the skill document\nSKILL_ID=$(rl managed-agents create-skill \\\n --data "{ \\"display_title\\": \\"Write release notes\\", \\"document\\": \\"---\\\\nname: write-release-notes\\\\ndescription: Turn a list of merged changes into release notes grouped by audience impact.\\\\n---\\\\n\\\\n# Write release notes\\\\n\\\\n1. Group the merged changes by who notices them: users, operators, nobody.\\\\n2. Drop the \\\\\\"nobody\\\\\\" group.\\\\n3. Write one line per change, in the reader\'s language, not the commit\'s.\\" }" \\\n | jq -r \'.skill_id\')\n\n# Attach the skill to the agent\nAGENT_VERSION_ID=$(rl managed-agents update-agent \\\n --agent_id "$AGENT_ID" \\\n --data "{ \\"agent_id\\": \\"$AGENT_ID\\", \\"skills\\": [{ \\"skill_id\\": \\"$SKILL_ID\\" }] }" \\\n | jq -r \'.latest_agent_version_id\')\n\n# Confirm the agent carries the skill\nATTACHED_SKILLS=$(rl managed-agents get-agent \\\n --agent_id "$AGENT_ID" \\\n | jq -r \'.skills\')',
6531
+ },
6532
+ curl: {
6533
+ setup: '# Create the agent the skill is for\nAGENT_ID=$(curl -s -X POST "https://api.recursion.labelbox.com/managed-agents/v1/agents" \\\n -H "Authorization: Bearer $LABELBOX_API_KEY" \\\n -H "Content-Type: application/json" \\\n -d "{ \\"model\\": \\"<gatewayModel>\\", \\"name\\": \\"Release notes writer\\", \\"system\\": \\"Follow the attached procedures exactly.\\" }" \\\n | jq -r \'.agent_id\')',
6534
+ main: '# Write the skill document\nSKILL_ID=$(curl -s -X POST "https://api.recursion.labelbox.com/managed-agents/v1/skills" \\\n -H "Authorization: Bearer $LABELBOX_API_KEY" \\\n -H "Content-Type: application/json" \\\n -d "{ \\"display_title\\": \\"Write release notes\\", \\"document\\": \\"---\\\\nname: write-release-notes\\\\ndescription: Turn a list of merged changes into release notes grouped by audience impact.\\\\n---\\\\n\\\\n# Write release notes\\\\n\\\\n1. Group the merged changes by who notices them: users, operators, nobody.\\\\n2. Drop the \\\\\\"nobody\\\\\\" group.\\\\n3. Write one line per change, in the reader\'s language, not the commit\'s.\\" }" \\\n | jq -r \'.skill_id\')\n\n# Attach the skill to the agent\nAGENT_VERSION_ID=$(curl -s -X PATCH "https://api.recursion.labelbox.com/managed-agents/v1/agents/$AGENT_ID" \\\n -H "Authorization: Bearer $LABELBOX_API_KEY" \\\n -H "Content-Type: application/json" \\\n -d "{ \\"agent_id\\": \\"$AGENT_ID\\", \\"skills\\": [{ \\"skill_id\\": \\"$SKILL_ID\\" }] }" \\\n | jq -r \'.latest_agent_version_id\')\n\n# Confirm the agent carries the skill\nATTACHED_SKILLS=$(curl -s -X GET "https://api.recursion.labelbox.com/managed-agents/v1/agents/$AGENT_ID" \\\n -H "Authorization: Bearer $LABELBOX_API_KEY" \\\n | jq -r \'.skills\')',
6535
+ },
6536
+ related: {
6537
+ requires: [
6538
+ {
6539
+ type: 'state',
6540
+ explanation: 'an agent exists to attach the skill to',
6541
+ via: {
6542
+ type: 'recipe',
6543
+ id: 'run-an-agent-session',
6544
+ },
6545
+ },
6546
+ ],
6547
+ learnMore: [
6548
+ {
6549
+ type: 'resource',
6550
+ id: 'managed-agents',
6551
+ },
6552
+ ],
6553
+ },
6554
+ },
6291
6555
  'grade-with-a-composite-grader': {
6292
6556
  id: 'grade-with-a-composite-grader',
6293
6557
  title: 'Grade with a composite grader',
@@ -9823,6 +10087,150 @@ export const RECIPE_REFERENCE = {
9823
10087
  ],
9824
10088
  },
9825
10089
  },
10090
+ 'run-an-agent-session': {
10091
+ id: 'run-an-agent-session',
10092
+ title: 'Run an agent session',
10093
+ goal: 'Give a managed agent a sandboxed environment and a task, then watch the session run to completion and read what it did.',
10094
+ category: 'managed-agents',
10095
+ video: 'run-an-agent-session.mp4',
10096
+ walkthrough: [
10097
+ {
10098
+ caption: 'Create the environment the agent works in',
10099
+ image: '01-create-the-environment-the-agent-works-in.png',
10100
+ description: 'The environment is the sandbox: its runtime, image, and setup commands are what the agent gets a shell in.',
10101
+ },
10102
+ {
10103
+ caption: 'Create the agent',
10104
+ image: '02-create-the-agent.png',
10105
+ description: 'An agent is a name, a system prompt, and a model — the definition a session snapshots.',
10106
+ },
10107
+ {
10108
+ caption: 'Start a session',
10109
+ image: '03-start-a-session.png',
10110
+ description: 'Starting is accepted, not finished: the response carries the session id to observe.',
10111
+ },
10112
+ {
10113
+ caption: 'Wait for the session to finish',
10114
+ image: '04-wait-for-the-session-to-finish.png',
10115
+ description: 'The session provisions its sandbox, runs the agent loop, and lands on a terminal status.',
10116
+ },
10117
+ {
10118
+ caption: 'Read what the agent did',
10119
+ image: '05-read-what-the-agent-did.png',
10120
+ description: 'The event timeline is the durable record of the run — messages, tool calls, and results.',
10121
+ },
10122
+ ],
10123
+ steps: [
10124
+ {
10125
+ kind: 'sdk',
10126
+ operationId: 'managedAgentsCreateEnvironment',
10127
+ caption: 'Create the environment the agent works in',
10128
+ phase: 'setup',
10129
+ inputs: {
10130
+ name: {
10131
+ value: 'Research sandbox',
10132
+ },
10133
+ provider: {
10134
+ value: 'runs',
10135
+ },
10136
+ description: {
10137
+ value: 'Sandbox for the quickstart research session.',
10138
+ },
10139
+ },
10140
+ captures: {
10141
+ environmentId: 'environment_id',
10142
+ },
10143
+ },
10144
+ {
10145
+ kind: 'sdk',
10146
+ operationId: 'managedAgentsCreateAgent',
10147
+ caption: 'Create the agent',
10148
+ phase: 'setup',
10149
+ inputs: {
10150
+ name: {
10151
+ value: 'Research assistant',
10152
+ },
10153
+ system: {
10154
+ value: 'Research the task, then write a concise report of what you found.',
10155
+ },
10156
+ model: {
10157
+ value: '<gatewayModel>',
10158
+ },
10159
+ },
10160
+ captures: {
10161
+ agentId: 'agent_id',
10162
+ },
10163
+ },
10164
+ {
10165
+ kind: 'sdk',
10166
+ operationId: 'managedAgentsStartSession',
10167
+ caption: 'Start a session',
10168
+ phase: 'main',
10169
+ inputs: {
10170
+ agent_id: {
10171
+ $ref: 'agentId',
10172
+ },
10173
+ environment_id: {
10174
+ $ref: 'environmentId',
10175
+ },
10176
+ message: {
10177
+ value: 'Write a one-paragraph summary of what a managed agent session is.',
10178
+ },
10179
+ },
10180
+ captures: {
10181
+ sessionId: 'session_id',
10182
+ },
10183
+ },
10184
+ {
10185
+ kind: 'sdk',
10186
+ operationId: 'managedAgentsGetSession',
10187
+ caption: 'Wait for the session to finish',
10188
+ phase: 'main',
10189
+ inputs: {
10190
+ session_id: {
10191
+ $ref: 'sessionId',
10192
+ },
10193
+ },
10194
+ captures: {
10195
+ sessionStatus: 'status',
10196
+ },
10197
+ },
10198
+ {
10199
+ kind: 'sdk',
10200
+ operationId: 'managedAgentsListSessionEvents',
10201
+ caption: 'Read what the agent did',
10202
+ phase: 'main',
10203
+ inputs: {
10204
+ session_id: {
10205
+ $ref: 'sessionId',
10206
+ },
10207
+ },
10208
+ captures: {
10209
+ events: 'events',
10210
+ },
10211
+ },
10212
+ ],
10213
+ sdk: {
10214
+ setup: "// Create the environment the agent works in\nconst managedAgent = await rl.managedAgents.createEnvironment({\n body: {\n description: 'Sandbox for the quickstart research session.',\n name: 'Research sandbox',\n provider: 'runs',\n },\n});\nconst environmentId = managedAgent.environment_id;\n\n// Create the agent\nconst managedAgent2 = await rl.managedAgents.createAgent({\n body: {\n model: '<gatewayModel>',\n name: 'Research assistant',\n system: 'Research the task, then write a concise report of what you found.',\n },\n});\nconst agentId = managedAgent2.agent_id;",
10215
+ main: "// Start a session\nconst managedAgent3 = await rl.managedAgents.startSession({\n body: {\n agent_id: agentId,\n environment_id: environmentId,\n message: 'Write a one-paragraph summary of what a managed agent session is.',\n },\n});\nconst sessionId = managedAgent3.session_id;\n\n// Wait for the session to finish\nlet managedAgent4;\nconst managedAgent4Deadline = Date.now() + 900000;\nfor (;;) {\n managedAgent4 = await rl.managedAgents.getSession({\n session_id: sessionId,\n });\n if (['failed', 'cancelled'].includes(managedAgent4.status)) throw new Error('reached a terminal failure state: ' + managedAgent4.status);\n if (['completed'].includes(managedAgent4.status)) break;\n if (Date.now() > managedAgent4Deadline) throw new Error('timed out after 900000ms waiting for a terminal state');\n await new Promise((resolve) => setTimeout(resolve, 10000));\n}\nconst sessionStatus = managedAgent4.status;\n\n// Read what the agent did\nconst managedAgent5 = await rl.managedAgents.listSessionEvents({\n session_id: sessionId,\n});\nconst events = managedAgent5.events;",
10216
+ },
10217
+ cli: {
10218
+ setup: '# Create the environment the agent works in\nENVIRONMENT_ID=$(rl managed-agents create-environment \\\n --data "{ \\"description\\": \\"Sandbox for the quickstart research session.\\", \\"name\\": \\"Research sandbox\\", \\"provider\\": \\"runs\\" }" \\\n | jq -r \'.environment_id\')\n\n# Create the agent\nAGENT_ID=$(rl managed-agents create-agent \\\n --data "{ \\"model\\": \\"<gatewayModel>\\", \\"name\\": \\"Research assistant\\", \\"system\\": \\"Research the task, then write a concise report of what you found.\\" }" \\\n | jq -r \'.agent_id\')',
10219
+ main: '# Start a session\nSESSION_ID=$(rl managed-agents start-session \\\n --data "{ \\"agent_id\\": \\"$AGENT_ID\\", \\"environment_id\\": \\"$ENVIRONMENT_ID\\", \\"message\\": \\"Write a one-paragraph summary of what a managed agent session is.\\" }" \\\n | jq -r \'.session_id\')\n\n# Wait for the session to finish\ndeadline=$(( $(date +%s) + 900 ))\nwhile :; do\n response=$(rl managed-agents get-session \\\n --session_id "$SESSION_ID")\n case "$(printf \'%s\' "$response" | jq -r \'.status\')" in failed|cancelled) echo "reached a terminal failure state: $response" >&2; exit 1 ;; esac\n case "$(printf \'%s\' "$response" | jq -r \'.status\')" in completed) break ;; esac\n [ "$(date +%s)" -ge "$deadline" ] && { echo "timed out waiting for a terminal state" >&2; exit 1; }\n sleep 10\ndone\nSESSION_STATUS=$(printf \'%s\' "$response" | jq -r \'.status\')\n\n# Read what the agent did\nEVENTS=$(rl managed-agents list-session-events \\\n --session_id "$SESSION_ID" \\\n | jq -r \'.events\')',
10220
+ },
10221
+ curl: {
10222
+ setup: '# Create the environment the agent works in\nENVIRONMENT_ID=$(curl -s -X POST "https://api.recursion.labelbox.com/managed-agents/v1/environments" \\\n -H "Authorization: Bearer $LABELBOX_API_KEY" \\\n -H "Content-Type: application/json" \\\n -d "{ \\"description\\": \\"Sandbox for the quickstart research session.\\", \\"name\\": \\"Research sandbox\\", \\"provider\\": \\"runs\\" }" \\\n | jq -r \'.environment_id\')\n\n# Create the agent\nAGENT_ID=$(curl -s -X POST "https://api.recursion.labelbox.com/managed-agents/v1/agents" \\\n -H "Authorization: Bearer $LABELBOX_API_KEY" \\\n -H "Content-Type: application/json" \\\n -d "{ \\"model\\": \\"<gatewayModel>\\", \\"name\\": \\"Research assistant\\", \\"system\\": \\"Research the task, then write a concise report of what you found.\\" }" \\\n | jq -r \'.agent_id\')',
10223
+ main: '# Start a session\nSESSION_ID=$(curl -s -X POST "https://api.recursion.labelbox.com/managed-agents/v1/sessions" \\\n -H "Authorization: Bearer $LABELBOX_API_KEY" \\\n -H "Content-Type: application/json" \\\n -d "{ \\"agent_id\\": \\"$AGENT_ID\\", \\"environment_id\\": \\"$ENVIRONMENT_ID\\", \\"message\\": \\"Write a one-paragraph summary of what a managed agent session is.\\" }" \\\n | jq -r \'.session_id\')\n\n# Wait for the session to finish\ndeadline=$(( $(date +%s) + 900 ))\nwhile :; do\n response=$(curl -s -X GET "https://api.recursion.labelbox.com/managed-agents/v1/sessions/$SESSION_ID" \\\n -H "Authorization: Bearer $LABELBOX_API_KEY")\n case "$(printf \'%s\' "$response" | jq -r \'.status\')" in failed|cancelled) echo "reached a terminal failure state: $response" >&2; exit 1 ;; esac\n case "$(printf \'%s\' "$response" | jq -r \'.status\')" in completed) break ;; esac\n [ "$(date +%s)" -ge "$deadline" ] && { echo "timed out waiting for a terminal state" >&2; exit 1; }\n sleep 10\ndone\nSESSION_STATUS=$(printf \'%s\' "$response" | jq -r \'.status\')\n\n# Read what the agent did\nEVENTS=$(curl -s -X GET "https://api.recursion.labelbox.com/managed-agents/v1/sessions/$SESSION_ID/events" \\\n -H "Authorization: Bearer $LABELBOX_API_KEY" \\\n | jq -r \'.events\')',
10224
+ },
10225
+ related: {
10226
+ learnMore: [
10227
+ {
10228
+ type: 'resource',
10229
+ id: 'managed-agents',
10230
+ },
10231
+ ],
10232
+ },
10233
+ },
9826
10234
  'run-an-evaluation': {
9827
10235
  id: 'run-an-evaluation',
9828
10236
  title: 'Run an evaluation',
@@ -129,7 +129,7 @@ export const RecipeManifestSchema = z
129
129
  // One-sentence statement of the user goal this recipe accomplishes.
130
130
  goal: z.string().min(1),
131
131
  // The canonical product domain this recipe lives under in the docs How-to nav
132
- // (one of the eight `DOMAINS`). Kebab here; membership in `DOMAINS` is enforced
132
+ // (one of the canonical `DOMAINS`). Kebab here; membership in `DOMAINS` is enforced
133
133
  // fail-fast by `recipes:generate` (it can't import the domains module — schema
134
134
  // files are loaded as source at codegen time, so they may only import npm deps).
135
135
  category: z.string().regex(KEBAB_CASE, 'category must be kebab-case'),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@labelbox/recursion-sdk",
3
- "version": "0.0.165",
3
+ "version": "0.0.166",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",