opencrowd 0.16.1 → 0.16.2

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 (2) hide show
  1. package/bundle/opencrowd.js +71 -13
  2. package/package.json +1 -1
@@ -15448,12 +15448,13 @@ function upstreamRefusalSummary(error53) {
15448
15448
  const detail = typeof refusal.message === "string" ? refusal.message.trim() : "";
15449
15449
  return `The model provider refused this request before any payment, so nothing was charged${detail ? `: ${detail}` : "."} You can retry or send another message.`;
15450
15450
  }
15451
- var RUN_FAILURE_MESSAGE, RUN_OUTCOMES, RunOutcomeSchema, RESUME_CAUSES, ResumeCauseSchema, RunStateSchema;
15451
+ var RUN_FAILURE_MESSAGE, PAYMENT_RECONCILING_MESSAGE, RUN_OUTCOMES, RunOutcomeSchema, RESUME_CAUSES, ResumeCauseSchema, RunStateSchema;
15452
15452
  var init_outcomes = __esm({
15453
15453
  "../../packages/protocol/dist/outcomes.js"() {
15454
15454
  "use strict";
15455
15455
  init_zod();
15456
15456
  RUN_FAILURE_MESSAGE = "Something went wrong. You can retry or send another message.";
15457
+ PAYMENT_RECONCILING_MESSAGE = "The model call was interrupted while its payment was in flight. CrowdCode is confirming that payment and will continue this run automatically; nothing is charged twice. You can also send a new message.";
15457
15458
  RUN_OUTCOMES = [
15458
15459
  "completed",
15459
15460
  "idle",
@@ -16151,15 +16152,19 @@ function isContextWindowError(value) {
16151
16152
  return true;
16152
16153
  return error53.error !== value && !!error53.error && isContextWindowError(typeof error53.error === "string" ? { message: error53.error } : error53.error);
16153
16154
  }
16154
- var MODEL_REQUEST_MAX_BYTES, MODEL_SELLER_REQUEST_MAX_BYTES, MODEL_MAX_MESSAGES, MODEL_GATEWAY_TIMEOUT_MS, MODEL_BRIDGE_TIMEOUT_MS, SERVICE_GATEWAY_TIMEOUT_MS, SERVICE_BRIDGE_TIMEOUT_MS, HOSTED_TOOL_BRIDGE_TIMEOUT_MS, HOSTED_CONTROL_TOOL_TIMEOUT_MS, SERVICE_RESPONSE_MAX_BYTES, DEFAULT_CONTEXT_WINDOW, ContextWindowExceeded, CONTEXT_COST_BUDGET_USD, CONTEXT_MIN_HISTORY_TOKENS, centsPer1kToUsdPerMillion;
16155
+ var MODEL_REQUEST_MAX_BYTES, MODEL_SELLER_REQUEST_MAX_BYTES, MODEL_MAX_MESSAGES, MODEL_PROVIDER_MAX_TIMEOUT_MS, MODEL_QUOTE_MAX_TIMEOUT_MS, MIB, MODEL_GATEWAY_TIMEOUT_MS, MODEL_GATEWAY_RETRY_BUDGET_MS, MODEL_BRIDGE_TIMEOUT_MS, SERVICE_GATEWAY_TIMEOUT_MS, SERVICE_BRIDGE_TIMEOUT_MS, HOSTED_TOOL_BRIDGE_TIMEOUT_MS, HOSTED_CONTROL_TOOL_TIMEOUT_MS, SERVICE_RESPONSE_MAX_BYTES, DEFAULT_CONTEXT_WINDOW, ContextWindowExceeded, CONTEXT_COST_BUDGET_USD, CONTEXT_MIN_HISTORY_TOKENS, centsPer1kToUsdPerMillion;
16155
16156
  var init_context = __esm({
16156
16157
  "../../packages/protocol/dist/context.js"() {
16157
16158
  "use strict";
16158
16159
  MODEL_REQUEST_MAX_BYTES = 16 * 1024 * 1024;
16159
16160
  MODEL_SELLER_REQUEST_MAX_BYTES = 5 * 1024 * 1024;
16160
16161
  MODEL_MAX_MESSAGES = 1e3;
16161
- MODEL_GATEWAY_TIMEOUT_MS = 42e4;
16162
- MODEL_BRIDGE_TIMEOUT_MS = 2 * MODEL_GATEWAY_TIMEOUT_MS + 3e4;
16162
+ MODEL_PROVIDER_MAX_TIMEOUT_MS = 48e4;
16163
+ MODEL_QUOTE_MAX_TIMEOUT_MS = 45e3;
16164
+ MIB = 1024 * 1024;
16165
+ MODEL_GATEWAY_TIMEOUT_MS = MODEL_QUOTE_MAX_TIMEOUT_MS + MODEL_PROVIDER_MAX_TIMEOUT_MS + 75e3;
16166
+ MODEL_GATEWAY_RETRY_BUDGET_MS = 33e4;
16167
+ MODEL_BRIDGE_TIMEOUT_MS = 2 * MODEL_GATEWAY_TIMEOUT_MS + MODEL_GATEWAY_RETRY_BUDGET_MS + 3e4;
16163
16168
  SERVICE_GATEWAY_TIMEOUT_MS = 33e4;
16164
16169
  SERVICE_BRIDGE_TIMEOUT_MS = MODEL_GATEWAY_TIMEOUT_MS + SERVICE_GATEWAY_TIMEOUT_MS + 3e4;
16165
16170
  HOSTED_TOOL_BRIDGE_TIMEOUT_MS = 9e4;
@@ -59205,6 +59210,7 @@ var init_gateway = __esm({
59205
59210
  artifact_path: artifact?.path,
59206
59211
  review_required: record3.review_required,
59207
59212
  review_available: true,
59213
+ ...result.note ? { note: result.note } : {},
59208
59214
  data: result.data,
59209
59215
  ...result.ok ? {} : { error: result.error }
59210
59216
  },
@@ -69573,7 +69579,7 @@ var init_crowdcode_venice = __esm({
69573
69579
  init_http3();
69574
69580
  init_dist2();
69575
69581
  init_providers();
69576
- CROWDCODE_VENICE_URL = "https://crowdcode.app/s/venice-reseller/chat/completions";
69582
+ CROWDCODE_VENICE_URL = "https://crowdcode.app/s/venice-proxy/chat/completions";
69577
69583
  CROWDCODE_VENICE_PAYEE = "0xeEc135BDe3C69e48Ce6Cf5b9e4520d65baf90FC3";
69578
69584
  VENICE_MODELS_URL = "https://api.venice.ai/api/v1/models?type=text";
69579
69585
  BASE_USDC2 = "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913";
@@ -87804,6 +87810,18 @@ var init_hosted_economy = __esm({
87804
87810
  if (reply.ok) {
87805
87811
  const data = objectValue5(reply.data) ?? {};
87806
87812
  const status = numberValue6(data.status);
87813
+ if (data.outcome === "owner_test") {
87814
+ const ok4 = status !== void 0 && status < 400;
87815
+ return {
87816
+ ok: ok4,
87817
+ ambiguous: false,
87818
+ status,
87819
+ data: decodeBody(data.body, data.content_type),
87820
+ authMode: "free",
87821
+ error: ok4 ? void 0 : `your service answered HTTP ${status ?? "?"}`,
87822
+ note: "This is your own service, so CrowdCode ran this call as a free owner test: nothing was paid or earned. Buyers pay the listed price as usual."
87823
+ };
87824
+ }
87807
87825
  const outcome = data.outcome === "paid_success" ? "paid_success" : "paid_failure";
87808
87826
  const paidAtomic = numberValue6(data.amount_atomic);
87809
87827
  const network = stringValue5(data.network);
@@ -88561,7 +88579,7 @@ var init_worker = __esm({
88561
88579
  await this.mutate(() => {
88562
88580
  run.pendingOperationId = error53.operationId;
88563
88581
  });
88564
- await this.finish(runId, run, error53.outcome === "payment_unknown" ? "failed" : error53.outcome, error53.outcome === "payment_unknown" ? RUN_FAILURE_MESSAGE : error53.message);
88582
+ await this.finish(runId, run, error53.outcome, error53.outcome === "payment_unknown" ? PAYMENT_RECONCILING_MESSAGE : error53.message);
88565
88583
  } else if (error53 instanceof SpendingDeclined)
88566
88584
  await this.finish(runId, run, "user_stopped", error53.message);
88567
88585
  else
@@ -88675,6 +88693,23 @@ var init_inbox = __esm({
88675
88693
  }
88676
88694
  });
88677
88695
 
88696
+ // ../../packages/agent-runtime/dist/non-answer.js
88697
+ function isNonAnswer(text) {
88698
+ const trimmed = text.trim();
88699
+ if (!trimmed || trimmed.length > 160 || /https?:\/\/|\n\s*\n/.test(trimmed))
88700
+ return false;
88701
+ return ACKNOWLEDGEMENT.test(trimmed) || PROMISE.test(trimmed);
88702
+ }
88703
+ var ACKNOWLEDGEMENT, ME, PROMISE;
88704
+ var init_non_answer = __esm({
88705
+ "../../packages/agent-runtime/dist/non-answer.js"() {
88706
+ "use strict";
88707
+ ACKNOWLEDGEMENT = /^(?:ok(?:ay)?|acknowledged|noted|understood|done|got it|sure|will do|on it|roger(?: that)?|thanks?(?: you)?|all done|complete(?:d)?|finished)(?:[.!]|\s*(?:—|-|,)\s*(?:thanks?(?: you)?|done))*$/i;
88708
+ ME = String.raw`(?:i(?:['’]?m| am)|i(?:['’]ll| will)(?: now)?|we(?:['’]re| are)|we(?:['’]ll| will)(?: now)?|now i(?:['’]ll| will)|next,? i(?:['’]ll| will)|let me(?: now)?|now,? let me|next,? let me)`;
88709
+ PROMISE = new RegExp(String.raw`^(?:${ME}\s+(?:now\s+|just\s+|going to\s+|about to\s+|currently\s+)*(?:prepar|compil|put(?:ting)?\b|writ|draft|gather|finali[sz]|summari[sz]|pull|assembl|format|work(?:ing)? on|get(?:ting)? (?:the|your|that|this)|provid|present|shar|send|deliver|giv)|(?:one moment|stand by|please wait|hang on|working on it|preparing|compiling|drafting|finali[sz]ing)\b)`, "i");
88710
+ }
88711
+ });
88712
+
88678
88713
  // ../../packages/agent-runtime/dist/index.js
88679
88714
  import { createHash as createHash6 } from "node:crypto";
88680
88715
  import { appendFile as appendFile4, mkdir as mkdir12, readFile as readFile15 } from "node:fs/promises";
@@ -88930,6 +88965,7 @@ async function runAgentTaskDetailed(session, task, options = {}) {
88930
88965
  let completionNudges = options.resume?.completionNudges ?? 0;
88931
88966
  let pendingFinalMessage = options.resume?.pendingFinalMessage;
88932
88967
  let finalAnswerHeld = options.resume?.finalAnswerHeld ?? false;
88968
+ let answerNudges = options.resume?.answerNudges ?? 0;
88933
88969
  let supersededFinalMessage;
88934
88970
  let outputContinuationNudges = options.resume?.outputContinuationNudges ?? 0;
88935
88971
  let outputContinuationPrefix = options.resume?.outputContinuationPrefix ?? "";
@@ -88946,6 +88982,7 @@ async function runAgentTaskDetailed(session, task, options = {}) {
88946
88982
  completionNudges,
88947
88983
  pendingFinalMessage,
88948
88984
  finalAnswerHeld,
88985
+ answerNudges,
88949
88986
  outputContinuationNudges,
88950
88987
  outputContinuationPrefix,
88951
88988
  serviceCallFailures,
@@ -88981,7 +89018,14 @@ async function runAgentTaskDetailed(session, task, options = {}) {
88981
89018
  else if (text.trim() !== pendingFinalMessage?.trim())
88982
89019
  supersededFinalMessage = text;
88983
89020
  };
88984
- const gateNudge = (blocker) => finalAnswerHeld ? `Your final answer is already saved and will be delivered to the user exactly as written; nothing you write now can replace it. Before this run ends: ${blocker} Then call complete_session again to finish; a one-line acknowledgement is enough, and do not restate the answer.` : `You cannot finish yet: ${blocker}`;
89021
+ const placeholder = () => !finalAnswerHeld && !!pendingFinalMessage && isNonAnswer(pendingFinalMessage) && messages.some((m) => m.role === "assistant" && m.toolCalls?.some((call2) => call2.name !== "complete_session"));
89022
+ const notAnAnswer = () => `Your final message so far ("${pendingFinalMessage.trim()}") is not an answer, and the user sees only your final message, never your tool results.`;
89023
+ const hold = () => {
89024
+ if (pendingFinalMessage?.trim() && !placeholder())
89025
+ finalAnswerHeld = true;
89026
+ };
89027
+ const gateNudge = (blocker) => finalAnswerHeld ? `Your final answer is already saved and will be delivered to the user exactly as written; nothing you write now can replace it. Before this run ends: ${blocker} Then call complete_session again to finish; a one-line acknowledgement is enough, and do not restate the answer.` : placeholder() ? `You cannot finish yet: ${blocker} ${notAnAnswer()} When you call complete_session again, put the complete answer to the user's request in it.` : `You cannot finish yet: ${blocker}`;
89028
+ const answerNudge = () => `${notAnAnswer()} Call complete_session again with the complete answer to the user's request: what you found or did, with the URLs, figures or identifiers they need.`;
88985
89029
  const withReflection = (summary2) => supersededFinalMessage ? { ...summary2, reflection_note: supersededFinalMessage } : summary2;
88986
89030
  const holding = () => finalAnswerHeld && !!pendingFinalMessage?.trim() && !options.signal?.aborted;
88987
89031
  const deliverHeld = async (turn, problem) => {
@@ -89077,17 +89121,23 @@ ${outputContinuationPrefix}`);
89077
89121
  const finalMessage = response.content.trim() ? outputContinuationPrefix + response.content : pendingFinalMessage ?? outputContinuationPrefix;
89078
89122
  recordFinalMessage(finalMessage);
89079
89123
  const blocker = await options.completionGate?.(completionNudges > 0);
89124
+ const unanswered = answerNudges < 1 && placeholder();
89080
89125
  if (blocker) {
89081
89126
  if (completionNudges >= 1) {
89127
+ hold();
89082
89128
  if (holding())
89083
89129
  return deliverHeld(turn, `the completion gate still blocks: ${blocker}`);
89084
89130
  const summary3 = await completeSession(session, `Stopped: ${blocker}`);
89085
89131
  return { outcome: "stopped", summary: summary3, turns: turn + 1 };
89086
89132
  }
89087
89133
  completionNudges += 1;
89088
- if (pendingFinalMessage?.trim())
89089
- finalAnswerHeld = true;
89090
- const nudge = { role: "user", content: gateNudge(blocker) };
89134
+ }
89135
+ if (blocker || unanswered) {
89136
+ if (unanswered)
89137
+ answerNudges += 1;
89138
+ hold();
89139
+ const content = blocker ? gateNudge(blocker) : answerNudge();
89140
+ const nudge = { role: "user", content };
89091
89141
  messages.push(nudge);
89092
89142
  await options.onMessage?.(nudge);
89093
89143
  await checkpoint(turn + 1);
@@ -89249,19 +89299,25 @@ ${outputContinuationPrefix}`);
89249
89299
  if (typeof finalMessage === "string")
89250
89300
  recordFinalMessage(finalMessage);
89251
89301
  const blocker = await options.completionGate?.(completionNudges > 0);
89302
+ const unanswered = answerNudges < 1 && placeholder();
89252
89303
  if (blocker) {
89253
89304
  if (completionNudges >= 1) {
89305
+ hold();
89254
89306
  if (holding())
89255
89307
  return deliverHeld(turn, `the completion gate still blocks: ${blocker}`);
89256
89308
  const summary3 = await completeSession(session, `Stopped: ${blocker}`);
89257
89309
  return { outcome: "stopped", summary: summary3, turns: turn + 1 };
89258
89310
  }
89259
89311
  completionNudges += 1;
89260
- if (pendingFinalMessage?.trim())
89261
- finalAnswerHeld = true;
89312
+ }
89313
+ if (blocker || unanswered) {
89314
+ if (unanswered)
89315
+ answerNudges += 1;
89316
+ hold();
89317
+ const content = blocker ? gateNudge(blocker) : answerNudge();
89262
89318
  const gateMessage = {
89263
89319
  role: "user",
89264
- content: gateNudge(blocker)
89320
+ content
89265
89321
  };
89266
89322
  messages.push(gateMessage);
89267
89323
  await options.onMessage?.(gateMessage);
@@ -89838,6 +89894,8 @@ var init_dist6 = __esm({
89838
89894
  init_knowledge();
89839
89895
  init_context2();
89840
89896
  init_tool_deadlines();
89897
+ init_non_answer();
89898
+ init_non_answer();
89841
89899
  MockLlmProvider = class {
89842
89900
  random;
89843
89901
  endProbability;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencrowd",
3
- "version": "0.16.1",
3
+ "version": "0.16.2",
4
4
  "description": "A CLI agent with its own wallet — discovers x402 services, pays in USDC, and completes tasks under a local budget",
5
5
  "type": "module",
6
6
  "license": "MIT",