@argosvix/sdk 0.4.22-alpha.0 → 0.5.0

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 (63) hide show
  1. package/README.md +4 -9
  2. package/dist/aiSdkMiddleware.d.ts +36 -20
  3. package/dist/aiSdkMiddleware.d.ts.map +1 -1
  4. package/dist/aiSdkMiddleware.js +98 -31
  5. package/dist/aiSdkMiddleware.js.map +1 -1
  6. package/dist/approvals.d.ts +37 -29
  7. package/dist/approvals.d.ts.map +1 -1
  8. package/dist/approvals.js +24 -18
  9. package/dist/approvals.js.map +1 -1
  10. package/dist/budgetGate.d.ts +30 -24
  11. package/dist/budgetGate.d.ts.map +1 -1
  12. package/dist/budgetGate.js +118 -92
  13. package/dist/budgetGate.js.map +1 -1
  14. package/dist/client.d.ts +15 -10
  15. package/dist/client.d.ts.map +1 -1
  16. package/dist/client.js +271 -222
  17. package/dist/client.js.map +1 -1
  18. package/dist/context.d.ts +59 -48
  19. package/dist/context.d.ts.map +1 -1
  20. package/dist/context.js +72 -58
  21. package/dist/context.js.map +1 -1
  22. package/dist/flush.d.ts +6 -4
  23. package/dist/flush.d.ts.map +1 -1
  24. package/dist/flush.js +6 -4
  25. package/dist/flush.js.map +1 -1
  26. package/dist/ids.d.ts +3 -2
  27. package/dist/ids.d.ts.map +1 -1
  28. package/dist/ids.js +6 -5
  29. package/dist/ids.js.map +1 -1
  30. package/dist/langchainCallback.d.ts +14 -13
  31. package/dist/langchainCallback.d.ts.map +1 -1
  32. package/dist/langchainCallback.js +22 -17
  33. package/dist/langchainCallback.js.map +1 -1
  34. package/dist/policyScan.d.ts +29 -22
  35. package/dist/policyScan.d.ts.map +1 -1
  36. package/dist/policyScan.js +47 -38
  37. package/dist/policyScan.js.map +1 -1
  38. package/dist/pricing.d.ts +5 -5
  39. package/dist/pricing.d.ts.map +1 -1
  40. package/dist/pricing.js +24 -22
  41. package/dist/pricing.js.map +1 -1
  42. package/dist/prompts.d.ts +20 -17
  43. package/dist/prompts.d.ts.map +1 -1
  44. package/dist/prompts.js +21 -17
  45. package/dist/prompts.js.map +1 -1
  46. package/dist/query.d.ts +21 -21
  47. package/dist/query.d.ts.map +1 -1
  48. package/dist/query.js +14 -14
  49. package/dist/recorder.d.ts +39 -19
  50. package/dist/recorder.d.ts.map +1 -1
  51. package/dist/recorder.js +120 -69
  52. package/dist/recorder.js.map +1 -1
  53. package/dist/redaction.d.ts +35 -33
  54. package/dist/redaction.d.ts.map +1 -1
  55. package/dist/redaction.js +73 -64
  56. package/dist/redaction.js.map +1 -1
  57. package/dist/types.d.ts +131 -114
  58. package/dist/types.d.ts.map +1 -1
  59. package/dist/version.d.ts +9 -9
  60. package/dist/version.d.ts.map +1 -1
  61. package/dist/version.js +9 -9
  62. package/dist/version.js.map +1 -1
  63. package/package.json +8 -2
package/dist/redaction.js CHANGED
@@ -1,87 +1,95 @@
1
1
  /**
2
2
  * Plaintext PII redaction for the captureContent opt-in path.
3
3
  *
4
- * Argosvix v1.x = Pro+ 平文保存機能の SDK opt-in 時に prompt / completion
5
- * 本文をそのまま送信する前に、 メールアドレス / クレジットカード番号 /
6
- * 電話番号 / マイナンバー / IP アドレスを自動マスキングするためのヘルパー。
4
+ * Helper that automatically masks email addresses / credit card numbers /
5
+ * phone numbers / Japanese My Number / IP addresses before prompt and
6
+ * completion bodies are sent verbatim under the Pro+ plaintext storage
7
+ * feature's SDK-side opt-in.
7
8
  *
8
- * 設計方針:
9
- * - false positive 寛容、false negative 厳禁(= 過剰マスクは OK、 PII の
10
- * 見落としは NG) ユーザーが明示的に disablePiiRedaction:true で無効化
11
- * しない限り、この関数が必ず通る
12
- * - 関数は純関数で副作用なし。 同じ入力に対して常に同じ出力
13
- * - 入力が空文字または null / undefined のときは入力をそのまま返す
14
- * - 入力が文字列でない場合(オブジェクト等) String() で文字列化してから
15
- * 置換、 ただし元の型は保たず string を返す
9
+ * Design policy:
10
+ * - False-positive tolerant, false negatives strictly avoided (over-masking
11
+ * is OK; missing PII is not). This function always runs unless the user
12
+ * explicitly disables it with disablePiiRedaction:true.
13
+ * - Pure function with no side effects. Same input always yields same output.
14
+ * - An empty string or null / undefined input is returned as-is.
15
+ * - Non-string input (objects etc.) is stringified with String() before
16
+ * replacement; the original type is not preserved — a string is returned.
16
17
  *
17
- * 既知の限界:
18
- * - 国際電話番号は形式が多様で全カバーは不可能。 conservative パターンで
19
- * +81-XX-XXXX-XXXX / 090-XXXX-XXXX 等の主要日本パターンと、 北米 (123)
20
- * 456-7890 形式を中心にカバー
21
- * - クレジットカード番号は Luhn check はしない(false positive 寛容)。
22
- * 13-19 桁の連続数字列(スペースとハイフン区切り含む)を一律置換
23
- * - マイナンバーは 12 桁数字。 クレジットカードと衝突する場合は 12 桁数字
24
- * が先に CC パターンにマッチする可能性あり = 結果は両方とも置換される
25
- * ので個人情報混入リスクとしては問題なし(マスキング種別が不正確に
26
- * なるだけ)
18
+ * Known limitations:
19
+ * - International phone number formats are too diverse to cover fully.
20
+ * Conservative patterns focus on the major Japanese forms
21
+ * (+81-XX-XXXX-XXXX / 090-XXXX-XXXX etc.) and the North American
22
+ * (123) 456-7890 form.
23
+ * - Credit card numbers are not Luhn-checked (false-positive tolerant).
24
+ * Any run of 13-19 digits (including space and hyphen separators) is
25
+ * replaced uniformly.
26
+ * - My Number is 12 digits. Where it collides with the credit card pattern,
27
+ * the 12-digit run may match the CC pattern first — either way both get
28
+ * replaced, so there is no PII-leak risk (only the masking category may
29
+ * be inaccurate).
27
30
  */
28
31
  /**
29
- * 2026-06-02 Round D = pattern 毎の type tag 追加 (= migration 0042
30
- * redaction_metadata counts JSON 集計するため、 regex がどの
31
- * カテゴリかを 明示する)。 metadata = { email: N, creditCard: N, ... }
32
+ * Each pattern carries a type tag so we can aggregate a counts JSON into the
33
+ * backend's redaction_metadata column each regex declares which category it
34
+ * belongs to. metadata = { email: N, creditCard: N, ... }.
32
35
  */
33
36
  const PATTERNS = [
34
- // Email = RFC 5322 ベース。 audit round2 fix = ASCII 限定パターンは IDN ドメイン
35
- // (例え.jp) や非ASCII local-part (山田@) を見落とした。 false-positive 寛容方針に従い
36
- // local/domain/TLD 非空白・非@ 文字に広げて 国際化アドレスも捕捉する。
37
+ // Email, RFC 5322 based. An earlier ASCII-only pattern missed IDN domains
38
+ // (e.g. Japanese-script domains under .jp) and non-ASCII local parts.
39
+ // Following the false-positive-tolerant policy, local/domain/TLD are widened
40
+ // to any non-whitespace, non-@ characters so internationalized addresses are
41
+ // also captured.
37
42
  {
38
43
  regex: /[^\s@]+@[^\s@]+\.[^\s@]{2,}/g,
39
44
  replacement: "[REDACTED_EMAIL]",
40
45
  type: "email",
41
46
  },
42
- // Credit card (= 改行・空白を跨ぐ番号もカバー)
43
- // Codex Round 1 MEDIUM 修正 = 「\d sep \d sep ...」 構造で carry すると
44
- // 最後の sep が次の \d を要求してしまい、 4111-1111-\n1111-1111 のような
45
- // 改行を跨いだケースで match が切れる。 先頭 \d + 後続 (sep* \d) {12,18}
46
- // で「区切りは複数連続可」 にして、 改行や複数空白も巻き込む。
47
+ // Credit card (also covers numbers spanning newlines and whitespace).
48
+ // A "\d sep \d sep ..." structure would make the trailing separator demand a
49
+ // following digit, breaking the match for newline-spanning cases like
50
+ // 4111-1111-\n1111-1111 (found in review). Using a leading \d followed by
51
+ // (sep* \d){12,18} allows multiple consecutive separators, so newlines and
52
+ // repeated spaces are swallowed too.
47
53
  {
48
- // audit round2 M31 fix = 区切り文字に '.' を追加。 pattern は space/tab/newline/hyphen
49
- // のみ許可していたため、 ドット区切りの番号 (4111.1111.1111.1111) CC に match せず、
50
- // 後段の phone pattern に先食いされて末尾 4 桁が平文残存していた。 CC phone より前に
51
- // 走るので、 ドットを CC 区切りに含めれば全桁 redact される (false-positive 寛容方針)。
54
+ // '.' added to the separator set (found in review): the old pattern only
55
+ // allowed space/tab/newline/hyphen, so dot-separated numbers
56
+ // (4111.1111.1111.1111) did not match as CC, got partially consumed by the
57
+ // later phone pattern, and left the last 4 digits in plaintext. Since CC
58
+ // runs before phone, including dots as CC separators redacts all digits
59
+ // (false-positive-tolerant policy).
52
60
  regex: /\b\d(?:[ \t\r\n.-]*\d){12,18}\b/g,
53
61
  replacement: "[REDACTED_CC]",
54
62
  type: "creditCard",
55
63
  },
56
- // マイナンバー = 12 桁数字、 単語境界で区切る
57
- // (上の CC パターンが先に走るので 12-13 桁の重複は CC で処理される)
64
+ // Japanese My Number = 12 digits, delimited by word boundaries
65
+ // (the CC pattern above runs first, so 12-13 digit overlaps are handled as CC)
58
66
  {
59
67
  regex: /\b\d{12}\b/g,
60
68
  replacement: "[REDACTED_MYNUMBER]",
61
69
  type: "myNumber",
62
70
  },
63
- // 電話番号 = 主要国の代表パターン:
64
- // - 日本 携帯: 090-XXXX-XXXX / 080-XXXX-XXXX / 070-XXXX-XXXX
65
- // - 日本 固定: 03-XXXX-XXXX / 06-XXXX-XXXX
66
- // - 国際: +81 90 XXXX XXXX / +1 (123) 456-7890
67
- // - 全角ハイフンや中黒は対象外(英数前提)
71
+ // Phone numbers = representative patterns for major countries:
72
+ // - Japan mobile: 090-XXXX-XXXX / 080-XXXX-XXXX / 070-XXXX-XXXX
73
+ // - Japan landline: 03-XXXX-XXXX / 06-XXXX-XXXX etc.
74
+ // - International: +81 90 XXXX XXXX / +1 (123) 456-7890
75
+ // - Fullwidth hyphens and middle dots are out of scope (ASCII assumed)
68
76
  {
69
77
  regex: /\+?\d{1,3}[-.\s]?\(?\d{2,4}\)?[-.\s]?\d{2,4}[-.\s]?\d{3,4}/g,
70
78
  replacement: "[REDACTED_PHONE]",
71
79
  type: "phone",
72
80
  },
73
- // IPv4 = 4 オクテット、 0-255 の範囲は厳密 check せず conservative
81
+ // IPv4 = 4 octets; the 0-255 range is not strictly checked — kept conservative
74
82
  {
75
83
  regex: /\b(?:\d{1,3}\.){3}\d{1,3}\b/g,
76
84
  replacement: "[REDACTED_IPV4]",
77
85
  type: "ipv4",
78
86
  },
79
- // IPv6 (フル形 + 短縮形) Codex Round 1 MEDIUM 修正で `::1` などの
80
- // 短縮表記を含めて拾えるよう、 hex group 0-4 (= group
81
- // 「::」 と一致) carry し、 lookbehind / lookahead 単語境界を担保。
82
- // `(?:[0-9a-fA-F]{0,4}:){2,7}[0-9a-fA-F]{1,4}` `::1` / `fe80::1234` /
83
- // 通常 8 group の全パターンを束ねる(false positive 寛容、 false negative
84
- // 厳禁の方針)
87
+ // IPv6 (full + shortened forms). To also catch shortened notations like
88
+ // `::1` (found in review), each hex group allows 0-4 digits (an empty group
89
+ // matches "::"), with lookbehind / lookahead providing the word boundaries.
90
+ // `(?:[0-9a-fA-F]{0,4}:){2,7}[0-9a-fA-F]{1,4}` bundles `::1` / `fe80::1234`
91
+ // and the ordinary 8-group form (false-positive tolerant, false negatives
92
+ // strictly avoided).
85
93
  {
86
94
  regex: /(?<![\w:.])(?:[0-9a-fA-F]{0,4}:){2,7}[0-9a-fA-F]{1,4}(?![\w:.])/g,
87
95
  replacement: "[REDACTED_IPV6]",
@@ -95,11 +103,12 @@ const PATTERNS = [
95
103
  * @returns The text with PII patterns replaced by [REDACTED_*] markers.
96
104
  */
97
105
  /**
98
- * audit round2 fix = 全角数字 (0-9 = U+FF10..FF19) を半角に正規化する。
99
- * 日本語 IME で入力された全角のクレジットカード番号・マイナンバー・電話番号・IP は
100
- * \d (= ASCII [0-9]) ベースの PII パターンを素通りしていた (= false negative)。
101
- * マッチ前に正規化することで全角 PII も確実に捕捉する (= 非PII の全角数字が半角化する
102
- * 副作用は false-positive 寛容方針で許容)。
106
+ * Normalize fullwidth digits (U+FF10..FF19) to ASCII. Fullwidth credit card
107
+ * numbers, My Number, phone numbers, and IPs typed via a Japanese IME slipped
108
+ * straight past the \d (ASCII [0-9]) based PII patterns a false negative.
109
+ * Normalizing before matching reliably captures fullwidth PII too (the side
110
+ * effect that non-PII fullwidth digits become halfwidth is accepted under the
111
+ * false-positive-tolerant policy).
103
112
  */
104
113
  function normalizeFullwidthDigits(s) {
105
114
  return s.replace(/[0-9]/g, (c) => String.fromCharCode(c.charCodeAt(0) - 0xfee0));
@@ -120,12 +129,12 @@ export function redactPii(input) {
120
129
  return result;
121
130
  }
122
131
  /**
123
- * 2026-06-02 Round D = 同 redaction 処理を 行いつつ、 type で 何回 置換
124
- * 発生したかを 同時 集計する。 backend redaction_metadata JSON 用 +
125
- * SDK 側で PII 含まれていたか」 判定 (= piiRedacted boolean) 用。
132
+ * Perform the same redaction while simultaneously counting how many
133
+ * replacements occurred per type. Feeds the backend redaction_metadata JSON
134
+ * and the SDK-side "did this contain PII" decision (the piiRedacted boolean).
126
135
  *
127
- * matchAll 経由で count 取り、 続けて replace carry。 regex g flag
128
- * なので 2 走らせても 副作用なし。
136
+ * Counts are taken via match, then the replacement is applied. The regexes use
137
+ * the g flag, so running them twice has no side effects.
129
138
  */
130
139
  export function redactPiiWithCounts(input) {
131
140
  if (input == null)
@@ -146,8 +155,8 @@ export function redactPiiWithCounts(input) {
146
155
  return { text: result, counts };
147
156
  }
148
157
  /**
149
- * 2026-06-02 Round D = 複数の redaction 結果 (= prompt / completion / 各 tool
150
- * call) counts 加算合成する helper。
158
+ * Helper that sums the counts from multiple redaction results (prompt /
159
+ * completion / each tool call).
151
160
  */
152
161
  export function mergeRedactionCounts(base, addition) {
153
162
  const out = { ...base };
@@ -157,8 +166,8 @@ export function mergeRedactionCounts(base, addition) {
157
166
  return out;
158
167
  }
159
168
  /**
160
- * 2026-06-02 Round D = counts object 1 件以上の redaction があるか。
161
- * piiRedacted boolean field の判定軸。
169
+ * Whether the counts object contains at least one redaction.
170
+ * The basis for the piiRedacted boolean field.
162
171
  */
163
172
  export function hasAnyRedaction(counts) {
164
173
  for (const v of Object.values(counts)) {
@@ -1 +1 @@
1
- {"version":3,"file":"redaction.js","sourceRoot":"","sources":["../src/redaction.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH;;;;GAIG;AACH,MAAM,QAAQ,GAAuE;IACnF,oEAAoE;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GAAG,GAA0D;QACjE,IAAI,EAAE,IAAI,CAAC,IAAI;KAChB,CAAC;IACF,IAAI,IAAI,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;QACjC,GAAG,CAAC,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC5C,CAAC;IACD,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QAC9B,GAAG,CAAC,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
package/dist/types.d.ts CHANGED
@@ -7,19 +7,23 @@ export interface ArgosvixConfig {
7
7
  /** Tags attached to every record (e.g. service / env / userId). */
8
8
  tags?: Record<string, string>;
9
9
  /**
10
- * provider opaque なエンドユーザー識別子 (OpenAI: safety_identifier、
11
- * Anthropic: metadata.user_id) を自動で `userId` タグに carry するか。 既定 true。
12
- * 既にこれらを provider へ渡しているアプリは設定ゼロで dashboard per-user 集計
13
- * (/users) が効く。 PII が入りやすい OpenAI 旧 `user` は対象外 (= 必要なら明示
14
- * `tags.userId` carry)。 明示の `tags.userId` があればそちらを優先 (= 上書き
15
- * しない) 自動取得を無効化したい場合のみ false を指定する。
10
+ * Whether to automatically map the provider's opaque end-user identifier
11
+ * (OpenAI: safety_identifier, Anthropic: metadata.user_id) into the `userId`
12
+ * tag. Defaults to true. Apps already passing these to the provider get the
13
+ * dashboard's per-user aggregation (/users) with zero configuration. The
14
+ * legacy OpenAI `user` field is excluded because it tends to contain PII
15
+ * (pass an explicit `tags.userId` if needed). An explicit `tags.userId`
16
+ * takes precedence (it is never overwritten). Set false only to disable the
17
+ * automatic capture.
16
18
  */
17
19
  captureUserId?: boolean;
18
20
  /**
19
- * 自動トレースコンテキスト伝播 (#1 R1)。 既定 on。 `withTrace(fn)` の内側で wrap した
20
- * LLM 呼び出しは明示 traceId なしで同じ trace に自動グルーピングされる。 false にすると
21
- * ambient コンテキストを無視し、 従来どおり明示 config.traceId のみで trace を組む。
22
- * AsyncLocalStorage が無いランタイム(= nodejs_als 無効の Workers 等)では自動的に無効。
21
+ * Automatic trace-context propagation. On by default. LLM calls wrapped
22
+ * inside `withTrace(fn)` are automatically grouped into the same trace
23
+ * without an explicit traceId. Setting false ignores the ambient context and
24
+ * builds traces only from an explicit config.traceId, as before.
25
+ * Automatically disabled on runtimes without AsyncLocalStorage (e.g. Workers
26
+ * without the nodejs_als flag).
23
27
  */
24
28
  autoContext?: boolean;
25
29
  /** Disable record submission entirely (e.g. for local dev). Defaults to false. */
@@ -48,117 +52,127 @@ export interface ArgosvixConfig {
48
52
  */
49
53
  provider?: Provider;
50
54
  /**
51
- * Trace ID = OTel subset trace (= 同一 user request / job 内の
52
- * 関連 LLM call 群)。 wrap() に渡すと この client の全 call record に
53
- * 自動付与される (= 1 wrap = 1 trace の運用)。 multi-call chain
54
- * trace を共有する場合は同じ traceId wrap、 chain なら wrap
55
- * or 上書き option 経由。 形式は user 自由 (= OTel hex / UUID / ULID /
56
- * 任意 string)、 最大 128 文字。
55
+ * Trace ID = the trace axis of the OTel subset (the group of related LLM
56
+ * calls within one user request / job). When passed to wrap(), it is
57
+ * automatically attached to every call record from this client (one wrap =
58
+ * one trace). To share a trace across a multi-call chain, wrap with the same
59
+ * traceId; for a different chain, use a separate wrap or the override
60
+ * option. The format is up to the user (OTel hex / UUID / ULID / arbitrary
61
+ * string), max 128 chars.
57
62
  */
58
63
  traceId?: string;
59
64
  /**
60
- * Span ID = この call (= wrap した client から発する LLM call 群)
61
- * span 識別子。 通常 wrap 単位で固定するより call 毎に動的に carry
62
- * する path の方が clean (= 別 phase で per-call option carry 予定)
63
- * MVP では wrap option 経由で 1 wrap = 1 span (= sub call 自動継承)
64
- * 許容するが、 founder dogfood では traceId のみで充分なケース多。
65
+ * Span ID = the span identifier for the LLM calls issued by the wrapped
66
+ * client. Deriving it dynamically per call is usually cleaner than fixing it
67
+ * per wrap (a per-call option is planned for a later phase). The MVP allows
68
+ * one wrap = one span via the wrap option (sub-calls inherit automatically),
69
+ * though in practice a traceId alone is often sufficient.
65
70
  */
66
71
  spanId?: string;
67
72
  /**
68
- * Parent span ID = この call の上流 / 直前 call span_id。 wrap 単位
69
- * で固定する path = ある工程の sub LLM call 全て同 parent を持つ
70
- * シンプル case を想定。
73
+ * Parent span ID = the span_id of this call's upstream / preceding call.
74
+ * Fixing it per wrap targets the simple case where all sub LLM calls of a
75
+ * given step share the same parent.
71
76
  */
72
77
  parentSpanId?: string;
73
78
  /**
74
- * Session ID = user の任意 group (= 連続会話 / 同 daily session /
75
- * job)。 trace (= OTel 軸の 1 request call group) より上位の
76
- * 概念で、 1 session 複数 trace 含み得る。 wrap() に渡すと
77
- * call record 自動付与され、 backend /v1/query/session/:id 経由で
78
- * dashboard conversation thread view carry。 形式は user 自由
79
- * (= UUID / ULID / 任意 string)、 最大 128 文字 [A-Za-z0-9_-]。
79
+ * Session ID = an arbitrary user-defined grouping axis (a continuous
80
+ * conversation / the same daily session / the same job). A higher-level
81
+ * concept than a trace (the OTel-style call group within one request); one
82
+ * session may contain multiple traces. When passed to wrap(), it is
83
+ * automatically attached to every call record and flows through the backend
84
+ * /v1/query/session/:id into the dashboard's conversation thread view. The
85
+ * format is up to the user (UUID / ULID / arbitrary string), max 128 chars
86
+ * [A-Za-z0-9_-].
80
87
  *
81
- * 2026-06-02 v0.4.0 で追加 (= v1.5 session tracking の SDK 側 carry)
88
+ * Added 2026-06-02 in v0.4.0 (SDK side of session tracking).
82
89
  */
83
90
  sessionId?: string;
84
91
  /**
85
- * Enable plaintext content capture (= Pro+ 平文保存機能の SDK opt-in)。
86
- * Default false true にすると、各 wrapper が prompt / completion 本文
87
- * tool call の引数・結果を抽出して record に乗せ、backend に送信する。
88
- * backend 側で account.plaintext_storage_optin = 1 のときに限り暗号化保管
89
- * される(env PLAINTEXT_STORAGE_ENABLED で全体 gate も併用)。
92
+ * Enable plaintext content capture (the SDK-side opt-in for the Pro+
93
+ * plaintext storage feature). Default false. When true, each wrapper
94
+ * extracts the prompt / completion bodies and tool call arguments/results,
95
+ * attaches them to the record, and sends them to the backend. They are
96
+ * stored encrypted only when account.plaintext_storage_optin = 1 on the
97
+ * backend (a global gate via the PLAINTEXT_STORAGE_ENABLED env is also applied).
90
98
  *
91
- * このフラグを true にする前に、ダッシュボードの設定画面で平文保存機能を
92
- * 有効化し、同意ダイアログでの明示同意を得ている必要がある。詳細は
93
- * https://argosvix.com/ja/docs/plaintext を参照。
99
+ * Before setting this flag to true, you must enable the plaintext storage
100
+ * feature in the dashboard settings and give explicit consent in the consent
101
+ * dialog. See https://argosvix.com/ja/docs/plaintext for details.
94
102
  */
95
103
  captureContent?: boolean;
96
104
  /**
97
105
  * Disable the built-in PII redaction filter that masks email / credit card /
98
- * phone / マイナンバー / IP address before send. Default false (= redaction
99
- * is ON) true にすると無加工で送信される個人情報混入のリスクは
100
- * ユーザーが負う(利用規約 4条の2 第7項)。
106
+ * phone / Japanese My Number / IP address before send. Default false
107
+ * (redaction is ON). When true, content is sent unmodified the user bears
108
+ * the risk of personal data exposure (Terms of Service, Article 4-2,
109
+ * Paragraph 7).
101
110
  *
102
- * captureContent false のときは平文自体送らないので、本フラグは無効。
111
+ * When captureContent is false, no plaintext is sent at all, so this flag
112
+ * has no effect.
103
113
  */
104
114
  disablePiiRedaction?: boolean;
105
115
  /**
106
- * Project ID = v1.5 Pro polish 追加 (= 2026-06-04)。 複数 product を 1
107
- * アカウントで 切り替えて 観測する path で 使う。 Pro = up to 5 projects
108
- * Team = unlimited。 wrap() に渡すと、 backend ingest 経路で
109
- * `X-Project-Id` header として 自動付与される (= 該当 project に record
110
- * が紐付く)。 未指定 = account default project に紐付く。
116
+ * Project ID. Used when observing multiple products under one account,
117
+ * switching between them. Pro = up to 5 projects, Team = unlimited. When
118
+ * passed to wrap(), it is automatically attached to the backend ingest path
119
+ * as the `X-Project-Id` header (records get associated with that project).
120
+ * When unset, records attach to the account's default project.
111
121
  *
112
- * 該当 account に紐付かない / archived project_id backend 404
113
- * 形式不正 (= /^[A-Za-z0-9_-]{1,128}$/) は 400 が返る (= fail-closed)。
122
+ * A project_id not belonging to the account or already archived returns 404
123
+ * from the backend; a malformed one (outside /^[A-Za-z0-9_-]{1,128}$/)
124
+ * returns 400 (fail-closed).
114
125
  *
115
- * 詳細 = https://argosvix.com/ja/docs/projects もしくは
116
- * dashboard Settings → Projects で project 一覧 + ID を取得。
126
+ * Details: https://argosvix.com/ja/docs/projects, or get the project list
127
+ * and IDs from the dashboard under Settings → Projects.
117
128
  */
118
129
  projectId?: string;
119
130
  /**
120
- * Runtime 予算ゲートの opt-in (= ランタイム制御プレーン Phase 1)
121
- * true にすると、wrap 済み client LLM 呼び出し前に backend
122
- * `/v1/gate/budget` の月次予算設定 + 当月消費額をローカル評価し、
123
- * 上限超過なら ArgosvixBudgetExceededError を投げて呼び出しを止める。
124
- * 設定 + 消費額は TTL キャッシュ (default 60s)、呼び出し毎の往復はしない。
125
- * gate 未設定の account では no-op Default false。
131
+ * Opt-in for the runtime budget gate (part of the runtime control plane).
132
+ * When true, before each LLM call on a wrapped client, the SDK locally
133
+ * evaluates the monthly budget settings plus current-month spend from the
134
+ * backend `/v1/gate/budget`, and if the limit is exceeded it throws
135
+ * ArgosvixBudgetExceededError to stop the call. Settings and spend use a TTL
136
+ * cache (default 60s) no round trip per call. A no-op on accounts without
137
+ * a configured gate. Default false.
126
138
  *
127
- * 既知の limitation: SDK wrap していない method (= Anthropic
128
- * `messages.stream()` 等、観測対象外の経路) enforce も対象外。 wrap 済み
129
- * method の一覧は README を参照。 上限を確実に強制したい場合は wrap 対象
130
- * method のみを使うこと。
139
+ * Known limitation: methods the SDK does not wrap (e.g. Anthropic
140
+ * `messages.stream()`, paths outside observation) are also outside
141
+ * enforcement. See the README for the list of wrapped methods. To enforce
142
+ * limits reliably, use only wrapped methods.
131
143
  */
132
144
  budgetGate?: boolean;
133
145
  /**
134
- * Runtime ポリシーゲートの opt-in (= ランタイム制御プレーン Phase 2)
135
- * true にすると、LLM 呼び出し前に backend のポリシー設定 (モデル allowlist /
136
- * PII block / secret block) SDK 内でローカル評価し、違反なら
137
- * ArgosvixPolicyViolationError を投げて呼び出しを止める。評価はプロキシ
138
- * 経由でなく顧客プロセス内で実行される。policy 未設定の account では no-op
139
- * budgetGate と独立に opt-in でき、設定の取得は同一 fetch (= /v1/gate/config)
140
- * を共有する。 Default false
146
+ * Opt-in for the runtime policy gate (part of the runtime control plane).
147
+ * When true, before each LLM call the SDK locally evaluates the backend's
148
+ * policy settings (model allowlist / PII block / secret block) and on a
149
+ * violation throws ArgosvixPolicyViolationError to stop the call. Evaluation
150
+ * runs inside the customer's process, not through a proxy. A no-op on
151
+ * accounts without a policy. Can be opted into independently of budgetGate;
152
+ * both share the same settings fetch (/v1/gate/config). Default false.
141
153
  */
142
154
  policyGate?: boolean;
143
155
  /**
144
- * budgetGate / policyGate true で、backend から gate 設定を一度も取得できていない
145
- * 段階の挙動。 default false (= fail-open、通す)。 true にすると取得成功
146
- * まで全呼び出しを ArgosvixBudgetGateUnavailableError で止める (= 厳格
147
- * 運用 opt-in) 取得後は backend gate の enforceMode に従う。
156
+ * Behavior while budgetGate / policyGate is true but the gate settings have
157
+ * never been fetched from the backend. Default false (fail-open, calls pass).
158
+ * When true, all calls are stopped with ArgosvixBudgetGateUnavailableError
159
+ * until the fetch succeeds (a strict-operation opt-in). After the fetch, the
160
+ * backend-side gate's enforceMode applies.
148
161
  */
149
162
  budgetGateFailClosed?: boolean;
150
163
  /**
151
- * policyGate cold start 厳格運用 opt-in (= R72b HIGH 1)。 backend
152
- * enforceMode (fail_closed) snapshot を一度取得した後にしか SDK から判定
153
- * できないため、 取得前の障害は default fail-open になる。 true にすると
154
- * 取得成功まで全呼び出しを ArgosvixBudgetGateUnavailableError で止める。
155
- * budgetGateFailClosed と同じ意味論で policy gate のみ使う構成向け。
164
+ * Strict cold-start opt-in for policyGate. The backend's enforceMode
165
+ * (fail_closed) can only be determined by the SDK after a snapshot has been
166
+ * fetched once, so failures before the first fetch default to fail-open.
167
+ * When true, all calls are stopped with ArgosvixBudgetGateUnavailableError
168
+ * until the fetch succeeds. Same semantics as budgetGateFailClosed, for
169
+ * setups using only the policy gate.
156
170
  */
157
171
  policyGateFailClosed?: boolean;
158
172
  /**
159
- * 予算ゲート設定の取得先 override (= self-host / test 用)。 未指定なら
160
- * `endpoint` と同 origin /v1/gate/budget それも無ければ
161
- * https://ingest.argosvix.com/v1/gate/budget
173
+ * Override for where budget gate settings are fetched from (for self-hosting
174
+ * / tests). When unset, /v1/gate/budget on the same origin as `endpoint`;
175
+ * failing that, https://ingest.argosvix.com/v1/gate/budget.
162
176
  */
163
177
  gateEndpoint?: string;
164
178
  }
@@ -170,21 +184,21 @@ export interface LlmCallRecord {
170
184
  promptTokens: number;
171
185
  completionTokens: number;
172
186
  totalTokens: number;
173
- /** プロンプトキャッシュ読取トークン(promptTokens の内数、割引課金)。なければ 0 */
187
+ /** Prompt-cache read tokens (a subset of promptTokens, billed at a discount). 0 if none. */
174
188
  cachedReadTokens?: number;
175
- /** プロンプトキャッシュ書込トークン(Anthropic のみ、プレミアム課金)。なければ 0 */
189
+ /** Prompt-cache write tokens (Anthropic only, billed at a premium). 0 if none. */
176
190
  cachedWriteTokens?: number;
177
191
  /** USD value with 6 decimal places (sufficient for GPT-4o input $5 / 1M tokens granularity). */
178
192
  costUsd: number;
179
- /** キャッシュ読取で削減できた USD(キャッシュ無し input との差額)。なければ 0 */
193
+ /** USD saved by cache reads (the difference versus uncached input). 0 if none. */
180
194
  cacheSavingsUsd?: number;
181
195
  /** End-to-end call latency in milliseconds. */
182
196
  latencyMs: number;
183
- /** 初回トークンまでの時間 ms(streaming のみ。非 streaming は未設定)。監査 Tier 2。 */
197
+ /** Time to first token in ms (streaming only; unset for non-streaming). */
184
198
  ttftMs?: number;
185
- /** 推論トークン(思考モデル。OpenAI completion_tokens_details.reasoning_tokens)。なければ未設定。 */
199
+ /** Reasoning tokens (thinking models; e.g. OpenAI completion_tokens_details.reasoning_tokens). Unset if none. */
186
200
  reasoningTokens?: number;
187
- /** 音声トークン(入力 + 出力の合算)。なければ未設定。 */
201
+ /** Audio tokens (input + output combined). Unset if none. */
188
202
  audioTokens?: number;
189
203
  /** ISO 8601 UTC timestamp. */
190
204
  timestamp: string;
@@ -209,33 +223,34 @@ export interface LlmCallRecord {
209
223
  temperature?: number;
210
224
  maxTokens?: number;
211
225
  };
212
- /** OTel subset trace = backend で集約 / waterfall view に carry。 */
226
+ /** OTel-subset trace axis aggregated on the backend and shown in the waterfall view. */
213
227
  traceId?: string;
214
228
  spanId?: string;
215
229
  parentSpanId?: string;
216
230
  /**
217
- * Session = trace より上位の user 任意 group (= 連続会話 / 同 daily
218
- * session / job)。 backend /v1/query/session/:id session_id
219
- * call 群を 取得、 dashboard conversation thread view で 時系列描画。
231
+ * Session axis = an arbitrary user-defined group above traces (a continuous
232
+ * conversation / the same daily session / the same job). The backend
233
+ * /v1/query/session/:id fetches the calls sharing a session_id, rendered
234
+ * chronologically in the dashboard's conversation thread view.
220
235
  */
221
236
  sessionId?: string;
222
237
  /**
223
- * Plaintext prompt body (= ArgosvixConfig.captureContent が true のときのみ
224
- * 設定される) ユーザーが LLM API に送信したテキスト本文。 PII redaction
225
- * が有効なら、メールアドレスやカード番号などが [REDACTED_*] に置換済み。
238
+ * Plaintext prompt body (only set when ArgosvixConfig.captureContent is
239
+ * true). The text body the user sent to the LLM API. If PII redaction is
240
+ * enabled, email addresses, card numbers, etc. have been replaced with
241
+ * [REDACTED_*].
226
242
  */
227
243
  promptBody?: string;
228
244
  /**
229
- * Plaintext completion body (= ArgosvixConfig.captureContent が true の
230
- * ときのみ設定される) LLM API からの応答テキスト本文。 PII redaction
231
- * 適用済み。
245
+ * Plaintext completion body (only set when ArgosvixConfig.captureContent is
246
+ * true). The response text body from the LLM API. PII redaction applied.
232
247
  */
233
248
  completionBody?: string;
234
249
  /**
235
- * Tool call (= function calling) の関数名と引数と結果。
236
- * captureContent true のときのみ設定される。 SDK response
237
- * tool_calls / function_call フィールドから抽出する。 引数と結果は PII
238
- * redaction 適用後の文字列(JSON 文字列の場合もある)
250
+ * Tool call (function calling) names, arguments, and results.
251
+ * Only set when captureContent is true. The SDK extracts these from the
252
+ * response's tool_calls / function_call fields. Arguments and results are
253
+ * strings after PII redaction (possibly JSON strings).
239
254
  */
240
255
  toolCalls?: Array<{
241
256
  name: string;
@@ -243,27 +258,29 @@ export interface LlmCallRecord {
243
258
  result?: string;
244
259
  }>;
245
260
  /**
246
- * 2026-06-02 Round D v0.4.1 = PII redaction 1 件以上適用された flag。
247
- * SDK 一次 redaction (= redactPiiWithCounts) email / creditCard /
248
- * myNumber / phone / ipv4 / ipv6 いずれかが 検出 + 置換されたら true。
249
- * backend 0042 schema の llm_calls.pii_redacted column carry。
250
- * disablePiiRedaction = true (= 無加工 carry) の場合は当然 false / unset。
261
+ * Flag set when at least one PII redaction was applied. True when the
262
+ * SDK-side primary redaction (redactPiiWithCounts) detected and replaced any
263
+ * of email / creditCard / myNumber / phone / ipv4 / ipv6. Stored in the
264
+ * backend's llm_calls.pii_redacted column. Naturally false / unset when
265
+ * disablePiiRedaction = true (content passed through unmodified).
251
266
  */
252
267
  piiRedacted?: boolean;
253
268
  /**
254
- * 2026-06-02 Round D v0.4.1 = redaction カテゴリ別件数 + redactor 識別子
255
- * JSON narrative。 backend 0042 schema llm_calls.redaction_metadata
256
- * column そのまま 保管、 dashboard / MCP server 「どの type いくつ
257
- * 検出したか」 監査表示に carry。
269
+ * Per-category redaction counts plus the redactor identifier, as JSON.
270
+ * Stored as-is in the backend's llm_calls.redaction_metadata column and
271
+ * surfaced by the dashboard / MCP server for the audit display of which
272
+ * types were detected and how many times.
258
273
  *
259
- * 例: { email: 2, phone: 1, creditCard: 0, redactor: "argosvix-sdk" }
274
+ * Example: { email: 2, phone: 1, creditCard: 0, redactor: "argosvix-sdk" }
260
275
  */
261
276
  redactionMetadata?: Record<string, unknown>;
262
277
  }
263
278
  /**
264
- * #1 R4 = 型付き/ネストの観測ノード(LLM ステップ) generation(= LlmCallRecord)以外の
265
- * span / event / retrieval / tool / agent / chain `withSpan` で emit し、 backend の
266
- * observations テーブルに保存する。 metadata は非機密の構造化属性のみ(件数 / サイズ等)。
279
+ * Typed / nested observation nodes (non-LLM steps). Beyond generations
280
+ * (LlmCallRecord), span / event / retrieval / tool / agent / chain nodes are
281
+ * emitted via `withSpan` and stored in the backend's observations table.
282
+ * Warning: metadata must contain only non-sensitive structured attributes
283
+ * (counts / sizes etc.).
267
284
  */
268
285
  export type ObservationType = "span" | "event" | "retrieval" | "tool" | "agent" | "chain";
269
286
  export interface ObservationRecord {